当在一页面使用$router.push跳转页面是时菜单树获取不到active
通过 this.$bus.$emit("getPath", "a");添加getPath方法,全局监听数据变化
back() {
this.$bus.$emit("getPath", "a");
this.$router.push("/a");
},
在树组件中
created() {
this.$bus.$on("getPath", (val) => {
this.active=val
console.log(val, "传递的数据");
});
},
这样就实现了