Vue Element 导航子路由不选中问题


  • 首先说下遇到的问题
    • 1.进入嵌套路由,当前父导航无法高亮显示
    • 2.页面刷新后导航重置问题
    • 3.在嵌套路由刷新页面也会导致导航重置问题

  • 接下来是解决方案:
    elementUI 里面有个属性 default-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
    }
},

这样就OK了

END


觉得有帮助的小伙伴点个赞支持下~

觉得有帮助的小伙伴点个赞~


免责声明!

本站转载的文章为个人学习借鉴使用,本站对版权不负任何法律责任。如果侵犯了您的隐私权益,请联系本站邮箱yoyou2525@163.com删除。



 
粤ICP备18138465号  © 2018-2025 CODEPRJ.COM