vue 页面刷新,路由跳转未匹配

页面刷新后,路由没有跳到相对应的导航栏

 

 

 

1. 我们可以通过获取当前$route.path,和导航栏的router进行匹配【当前使用了 lodash 的 map 遍历导航栏列表【this.navList】】

_.map(this.navList, (item, index) => {
        if (this.$route.path.replace(/\//g, '') === item.router) {
          this.currentIndex = index
        }
      })

 

posted @ 2019-12-05 15:30  包子不包子  阅读(712)  评论(0编辑  收藏  举报