mirror of
https://codeup.aliyun.com/67762337eccfc218f6110e0e/vue/learning-system-portal.git
synced 2025-12-10 11:26:43 +08:00
测试
This commit is contained in:
@@ -30,24 +30,20 @@ import portalFooter from "@/components/PortalFooter.vue";
|
|||||||
window.addEventListener('message', this.handleMessageFromChild);
|
window.addEventListener('message', this.handleMessageFromChild);
|
||||||
},
|
},
|
||||||
beforeDestroy() {
|
beforeDestroy() {
|
||||||
// 移除事件监听器
|
window.removeEventListener('message', this.handleMessageFromChild);
|
||||||
window.removeEventListener('message', this.handleMessageFromChild);
|
},
|
||||||
},
|
|
||||||
methods:{
|
methods:{
|
||||||
handleMessageFromChild(event) {
|
handleMessageFromChild(event) {
|
||||||
console.log(event,'我进来了')
|
if (event.origin !== process.env.VUE_APP_BOE_MOBILE_URL) return;
|
||||||
if (event.origin !== process.env.VUE_APP_BOE_MOBILE_URL) return; // 验证来源以防跨站脚本攻击
|
if (event.data && event.data.type === 'navigate') {
|
||||||
if (event.data && event.data.type === 'navigate') {
|
this.navigate(event.data.path);
|
||||||
this.navigate(event.data.path);
|
}
|
||||||
}
|
},
|
||||||
},
|
navigate(path) {
|
||||||
navigate(path) {
|
this.$router.push({
|
||||||
// 清除查询参数
|
path:path
|
||||||
// 这里假设iframe加载的是子项目,可以通过改变iframe的src属性来导航
|
})
|
||||||
this.$router.push({
|
},
|
||||||
path:path
|
|
||||||
})
|
|
||||||
},
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
</script>
|
</script>
|
||||||
|
|||||||
Reference in New Issue
Block a user