Commit b1bdd036 by tang

feat: 监听路由变换,高亮导航

parent e23b2794
......@@ -56,7 +56,7 @@
</el-menu>
</template>
<script>
import { mapState } from "vuex";
import {mapState} from "vuex";
export default {
data() {
......@@ -81,12 +81,20 @@ export default {
(item) => item.link === this.$route.path
);
if (result) {
console.log(result);
this.activeMenu = result.id;
}
},
immediate: true,
},
$route(to, from) {
const result = this.treeFind(
this.subNav,
(item) => item.link === this.$route.path
);
if (result) {
this.activeMenu = result.id;
}
}
},
methods: {
treeFind(tree, func) {
......@@ -147,7 +155,7 @@ export default {
if (item.breadcrumb) {
this.$store.commit("system/SET_BREADCRUMB", item.breadcrumb);
}
this.$router.push({ path: item.link });
this.$router.push({path: item.link});
}
},
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment