no message

This commit is contained in:
kuaifan 2025-08-04 06:02:22 +08:00
parent acdf23571c
commit 4f2bf7549c

View File

@ -80,15 +80,14 @@ export default {
this.boundHandleLoad = this.handleLoad.bind(this);
this.boundHandleError = this.handleError.bind(this);
this.injectMicroApp();
window.addEventListener('message', this.boundHandleMessage);
this.$refs.iframe.addEventListener('load', this.boundHandleLoad);
this.$refs.iframe.addEventListener('error', this.boundHandleError);
this.injectMicroApp();
},
beforeDestroy() {
this.cleanupMicroApp();
//
if (this.boundHandleMessage) {
window.removeEventListener('message', this.boundHandleMessage);
@ -360,7 +359,7 @@ export default {
const iframeWindow = this.$refs.iframe.contentWindow
if (iframeWindow && this.data) {
try {
// microApp
// microApp
iframeWindow.microApp = {
getData: () => this.data
}
@ -379,18 +378,6 @@ export default {
// console.error('Failed to inject microApp object:', error)
}
},
// microApp
cleanupMicroApp() {
try {
const iframeWindow = this.$refs.iframe.contentWindow
if (iframeWindow && iframeWindow.microApp) {
delete iframeWindow.microApp
}
} catch (error) {
// console.error('Failed to clean up microApp object:', error)
}
},
}
}
</script>