Browse Source

feat(editor): 添加窗口消息监听器

- 在 ModelMain 组件中添加了 window message 事件监听器
- 监听函数为 this.mes,用于处理接收到的消息
- 在组件卸载时移除消息监听器,避免内存泄漏
master
lizw-2015 5 months ago
parent
commit
43decc46c7
  1. 6
      src/editor/ModelMain.vue

6
src/editor/ModelMain.vue

@ -175,9 +175,12 @@ export default {
} }
this.editorHash += 1 // this.editorHash += 1 //
}) })
window.addEventListener('message', this.mes)
}, },
unmounted() { unmounted() {
ModelMainUnmounted() ModelMainUnmounted()
window.removeEventListener('message', this.mes)
}, },
data() { data() {
return { return {
@ -253,6 +256,9 @@ export default {
methods: { methods: {
renderIcon, renderIcon,
getWidgetBySide, getWidgetBySide,
mes(event) {
console.log('data', event.data);
},
toHome() { toHome() {
system.router.push({ name: 'home' }) system.router.push({ name: 'home' })
}, },

Loading…
Cancel
Save