<template> <div> <menu-component class="monitor_menu" :menuList="list" :active="active"></menu-component> </div> </template> <script> import menuComponent from '../components/menu-component' import { mapState } from 'vuex' export default { data() { return { list: [], active: '' } }, components: { menuComponent }, computed: { ...mapState('d2admin/menu', [ 'header' ]) }, watch: { '$route.matched': { handler (val) { this.$nextTick(()=>{ this.active='' this.active = val[1].path }) }, immediate: true } }, created () { this.header.forEach(res => { if (res.path === '/access') { this.list = res.list; this.active=this.$route.path // this.active = res.list[0].path; // this.$router.push({ // path: res.list[0].path, // }) } }) } } </script>