fix: 修复菜单组件会重复监听事件的问题

This commit is contained in:
shiziyuan9527 2021-01-04 15:44:38 +08:00
parent b9b95d63d8
commit ad597dcd79
3 changed files with 9 additions and 3 deletions

View File

@ -97,7 +97,6 @@ export default {
methods: { methods: {
registerEvents() { registerEvents() {
ApiEvent.$on(LIST_CHANGE, () => { ApiEvent.$on(LIST_CHANGE, () => {
// // todo refs
this.$refs.testRecent.recent(); this.$refs.testRecent.recent();
this.$refs.reportRecent.recent(); this.$refs.reportRecent.recent();
}); });
@ -111,6 +110,9 @@ export default {
}, },
mounted() { mounted() {
this.registerEvents(); this.registerEvents();
},
beforeDestroy() {
ApiEvent.$off(LIST_CHANGE);
} }
} }

View File

@ -84,7 +84,6 @@ export default {
methods: { methods: {
registerEvents() { registerEvents() {
PerformanceEvent.$on(LIST_CHANGE, () => { PerformanceEvent.$on(LIST_CHANGE, () => {
// // todo refs
this.$refs.testRecent.recent(); this.$refs.testRecent.recent();
this.$refs.reportRecent.recent(); this.$refs.reportRecent.recent();
}); });
@ -92,6 +91,9 @@ export default {
}, },
mounted() { mounted() {
this.registerEvents(); this.registerEvents();
},
beforeDestroy() {
PerformanceEvent.$off(LIST_CHANGE);
} }
} }

View File

@ -131,11 +131,13 @@ export default {
}, },
registerEvents() { registerEvents() {
TrackEvent.$on(LIST_CHANGE, () => { TrackEvent.$on(LIST_CHANGE, () => {
// // todo refs
this.$refs.planRecent.recent(); this.$refs.planRecent.recent();
this.$refs.caseRecent.recent(); this.$refs.caseRecent.recent();
}); });
} }
},
beforeDestroy() {
TrackEvent.$off(LIST_CHANGE);
} }
} }