vue中 evenBus调用,兄弟间传值
作者:互联网
main.js中----------
new Vue({ router, store, data: { eventHub: new Vue() }, render: h => h(App), watch: { '$route.path': function(newVal, oldVal) { const userId = this.$route.query.userId || localStorage.getItem('userIds'); const parkId = this.$route.query.id || localStorage.getItem('parkId'); this.$router.push({ query: { id: parkId, userId: userId } }); localStorage.setItem('userIds', userId); localStorage.setItem('parkId', parkId); } } }).$mount("#app");
this.$root.eventHub.$on("controlbgChange", (res) => { console.log('res',res) });
this.$root.eventHub.$emit("controlbgChange", path);
标签:vue,evenBus,userId,parkId,localStorage,eventHub,res,query,传值 来源: https://www.cnblogs.com/Byme/p/14662589.html