Commit b1bdd036 by tang

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

parent e23b2794
...@@ -56,7 +56,7 @@ ...@@ -56,7 +56,7 @@
</el-menu> </el-menu>
</template> </template>
<script> <script>
import { mapState } from "vuex"; import {mapState} from "vuex";
export default { export default {
data() { data() {
...@@ -81,12 +81,20 @@ export default { ...@@ -81,12 +81,20 @@ export default {
(item) => item.link === this.$route.path (item) => item.link === this.$route.path
); );
if (result) { if (result) {
console.log(result);
this.activeMenu = result.id; this.activeMenu = result.id;
} }
}, },
immediate: true, immediate: true,
}, },
$route(to, from) {
const result = this.treeFind(
this.subNav,
(item) => item.link === this.$route.path
);
if (result) {
this.activeMenu = result.id;
}
}
}, },
methods: { methods: {
treeFind(tree, func) { treeFind(tree, func) {
...@@ -147,7 +155,7 @@ export default { ...@@ -147,7 +155,7 @@ export default {
if (item.breadcrumb) { if (item.breadcrumb) {
this.$store.commit("system/SET_BREADCRUMB", 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