- First, that problem encountered
- 1. Go to the nested routing, navigation current parent can not be highlighted
- When the page refreshes navigation reset problem
- 3. Refresh the page in a nested navigation routes can also cause problems reset
- Next is the solution:
ElementUI there are attributes default-active (menu of the currently active index)
<el-menu :default-active="activeIndex" @select="handleSelect" router></el-menu>
data () {
return {
activeIndex: '/'
}
},
watch: {
'$route' () {
this.handleSelect(this.activeIndex)
}
},
mounted () {
this.activeIndex = this.$route.matched[0].path || '/'
},
methods: {
handleSelect (index) {
this.activeIndex = index
}
},
This OK