main.js
new Vue({
render: h => h(App),
beforeCreate() {
Vue.prototype.$bus = this;
},
//注册路由信息,注册之后组件带有$route $router属性
router,
//注册仓库,注册之后组件带有$store属性
store
}).$mount('#app')
事件发起方
this.$bus.$emit("imageClick", index);
事件接收方
mounted() {
this.$bus.$on("imageClick", (index) => {
this.index = index;
});
},