问题
解决方法:兄弟组件传值,重新改变tab值
新建bus.js文件
import Vue from "vue";
export default new Vue();
foot组件,点击事件
import Bus from '../../common/js/bus.js'
goagreement(i) {
if (this.$route.path.includes("agreement")) {
Bus.$emit("type", i); //当前页面,为兄弟组件
} else {
this.$router.push({
path: "/agreement",
query: {
type: i
}
});
}
}
agreement页面接受type值
import Bus from '../../common/js/bus.js'
created() {
Bus.$on("type", (val) => { //取 Bus.$on
this.type = val //重新赋值
})
},
在组件销毁前使用$off方法取消事件监听
Bus.$off('type');