| | |
| | | :class="{'show-this':menu.subShow, 'show-this-hover':menu.subShowHover}"> |
| | | <ul> |
| | | <li v-for="(children, sKey) in menu.childrens" :key="sKey"> |
| | | <a |
| | | :href="children.url" |
| | | <router-link |
| | | :to="children.url" |
| | | :class="{active: children.active}" |
| | | @click="subClick(key, sKey)"> |
| | | @click.native="subClick(key, sKey)"> |
| | | {{children.txt}} |
| | | </a> |
| | | </router-link> |
| | | </li> |
| | | </ul> |
| | | </div> |
| | |
| | | subShowHover:false, // 是否显示对应的子导航 |
| | | childrens: [ |
| | | { |
| | | txt: '状态信息', |
| | | url: '#', |
| | | txt: '状态显示', |
| | | url: '/home/state', |
| | | active: true |
| | | }, |
| | | { |
| | | txt: '账户信息', |
| | | url: '#', |
| | | url: '/home/account', |
| | | active: false |
| | | }, |
| | | { |
| | |
| | | childrens: [ |
| | | { |
| | | txt: '过程监控', |
| | | url: '#', |
| | | url: '/monitor/process', |
| | | active: false |
| | | }, |
| | | { |
| | | txt: '通道选择', |
| | | url: '#', |
| | | url: '/monitor/channnel', |
| | | active: false |
| | | }, |
| | | { |
| | | txt: '信息显示', |
| | | url: '#', |
| | | url: '/monitor/info', |
| | | active: false |
| | | } |
| | | ] |
| | |
| | | childrens: [ |
| | | { |
| | | txt: '故障诊断', |
| | | url: '#', |
| | | url: '/testing/fault', |
| | | active: false |
| | | }, |
| | | { |
| | |
| | | childrens: [ |
| | | { |
| | | txt: '故障分析', |
| | | url: '#', |
| | | url: '/data/failure', |
| | | active: false |
| | | }, |
| | | { |
| | |
| | | menu.subShow = true; |
| | | menu.active = true; |
| | | children.active = true; |
| | | }, |
| | | setMenuState: function(path) { |
| | | var key = 0; |
| | | var skey = 0; |
| | | // 遍历menu的值 |
| | | for(var i=0; i<this.menus.length; i++) { |
| | | var menu = this.menus[i]; |
| | | var childrens = menu.childrens; |
| | | for(var k=0; k<childrens.length; k++){ |
| | | var children = childrens[k]; |
| | | if(children.url != '#' && children.url == path) { |
| | | key = i; |
| | | skey = k; |
| | | } |
| | | } |
| | | } |
| | | |
| | | this.subClick(key, skey); |
| | | } |
| | | }, |
| | | mounted: function() { |
| | | var path = this.$route.path; |
| | | var store = this.$store; |
| | | // 根据路由设置导航状态 |
| | | this.setMenuState(store.state.path); |
| | | } |
| | | } |
| | | </script> |