Skip to content

Commit 4f2bf75

Browse files
committed
no message
1 parent acdf235 commit 4f2bf75

File tree

1 file changed

+3
-16
lines changed
  • resources/assets/js/components/MicroApps

1 file changed

+3
-16
lines changed

resources/assets/js/components/MicroApps/iframe.vue

Lines changed: 3 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -80,15 +80,14 @@ export default {
8080
this.boundHandleLoad = this.handleLoad.bind(this);
8181
this.boundHandleError = this.handleError.bind(this);
8282
83-
this.injectMicroApp();
8483
window.addEventListener('message', this.boundHandleMessage);
8584
this.$refs.iframe.addEventListener('load', this.boundHandleLoad);
8685
this.$refs.iframe.addEventListener('error', this.boundHandleError);
86+
87+
this.injectMicroApp();
8788
},
8889
8990
beforeDestroy() {
90-
this.cleanupMicroApp();
91-
9291
// 正确移除事件监听器
9392
if (this.boundHandleMessage) {
9493
window.removeEventListener('message', this.boundHandleMessage);
@@ -360,7 +359,7 @@ export default {
360359
const iframeWindow = this.$refs.iframe.contentWindow
361360
if (iframeWindow && this.data) {
362361
try {
363-
// 直接注入 microApp 对象
362+
// 同源情况,直接注入 microApp 对象
364363
iframeWindow.microApp = {
365364
getData: () => this.data
366365
}
@@ -379,18 +378,6 @@ export default {
379378
// console.error('Failed to inject microApp object:', error)
380379
}
381380
},
382-
383-
// 清理注入的 microApp 对象
384-
cleanupMicroApp() {
385-
try {
386-
const iframeWindow = this.$refs.iframe.contentWindow
387-
if (iframeWindow && iframeWindow.microApp) {
388-
delete iframeWindow.microApp
389-
}
390-
} catch (error) {
391-
// console.error('Failed to clean up microApp object:', error)
392-
}
393-
},
394381
}
395382
}
396383
</script>

0 commit comments

Comments
 (0)