vue + ElementUI 点击页面内按钮跳转,导航栏选中问题

版权声明:本文为博主原创文章,未经博主允许不得转载。 https://blog.csdn.net/qq_34117170/article/details/80758575

vue + ElementUI 点击导航栏跳转页面是可以正常跳转高亮的,但通过页面内点击按钮跳转页面就会导致侧边栏不知道该选中那个了,下面说下解决方法

 <el-menu class="sidebar-el-menu"  :default-active="onRoutes" >
            </el-menu>
     computed:{
            onRoutes(){
                // this.$route.path
                // debugger
                if(this.$route.path.replace('/','')=='ProductEdit'){
                   return 'Product'; 
                }
                else if(this.$route.path.replace('/','')=='OrderDetail'){
                    return 'Order'
                }
                else{
                    return this.$route.path.replace('/','');
                }

            },
            }

花了一个多小时终于搞定

猜你喜欢

转载自blog.csdn.net/qq_34117170/article/details/80758575
今日推荐