mirror of
https://codeup.aliyun.com/67762337eccfc218f6110e0e/vue/learning-system-portal.git
synced 2025-12-08 02:16:43 +08:00
测试
This commit is contained in:
@@ -27,29 +27,23 @@ import portalFooter from "@/components/PortalFooter.vue";
|
||||
if(params){
|
||||
this.url=this.url+'?'+params;
|
||||
}
|
||||
window.addEventListener('hashchange', this.handleHashChange);
|
||||
window.addEventListener('popstate', this.handlePopState);
|
||||
window.addEventListener('message', this.handleMessageFromChild);
|
||||
},
|
||||
beforeDestroy() {
|
||||
window.removeEventListener('hashchange', this.handleHashChange);
|
||||
window.removeEventListener('popstate', this.handlePopState);
|
||||
},
|
||||
window.removeEventListener('message', this.handleMessageFromChild);
|
||||
},
|
||||
methods:{
|
||||
handleHashChange() {
|
||||
this.navigate();
|
||||
},
|
||||
handlePopState() {
|
||||
this.navigate();
|
||||
},
|
||||
navigate() {
|
||||
const navigatePath = new URLSearchParams(window.location.search).get('navigate');
|
||||
if (navigatePath) {
|
||||
// 清除查询参数
|
||||
window.history.replaceState({}, '', location.pathname);
|
||||
// 导航
|
||||
this.$refs.iframe.src = navigatePath;
|
||||
}
|
||||
},
|
||||
handleMessageFromChild(event) {
|
||||
if (event.origin !== process.env.VUE_APP_BOE_MOBILE_URL) return;
|
||||
if (event.data && event.data.type === 'navigate') {
|
||||
this.navigate(event.data.path);
|
||||
}
|
||||
},
|
||||
navigate(path) {
|
||||
this.$router.push({
|
||||
path:path
|
||||
})
|
||||
},
|
||||
}
|
||||
}
|
||||
</script>
|
||||
|
||||
Reference in New Issue
Block a user