Vue系列 => [BUG] 面包屑导航切换到首页 侧导航栏激活问题

79 阅读1分钟

vue监听$route变化,报错:

Error in callback for watcher “$route”: “TypeError: Cannot read property ‘call’ of undefined”

watch: {
   // 如果路由有变化,会再次执行该方法
    $route: function(newV) {
      console.log(newV)
      if (newV.path == '/welcome') {
        this.activeStatus = ''
      }
    }
  }

解决方法

检查函数function是否在method下面

newV.path == '/welcome'