index.vue 939 Bytes
Newer Older
geqilin's avatar
geqilin committed
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49
<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 === '/patrol') {
        this.list = res.list
        this.active=this.$route.path

        // this.active = res.list[0].path
        // this.$router.push({
        //   path: res.list[0].path,
        // })
      }
    })
  }
}
</script>