为什么vue监听$route时路由跳转没反应?

新手上路,请多包涵

问题描述

路由跳转没监听到

问题出现的环境背景及自己尝试过哪些方法

   beforeRouteEnter (to, from, next) {
      console.log('ooo')

  },
  '$route' :{    //失效,路由改变了不知道为什么不走
    handler:function(to,from){
      console.log(to,from)
      // if(to.path == '/'){
      //   /**
      //    * $store来自Store对象
      //    * dispatch 向 actions 发起请求
      //    */
      //   this.$store.dispatch('showTabBar');
      // }else{
      //   this.$store.dispatch('hideTabBar');
      // }
    },
    deep:true
  },
  '$route'(to, from) {
      console.log(to,from)
    console.log('ooo')
    
  },

相关代码

// 请把代码文本粘贴到下方(请勿用图片代替代码)

图片描述

你期待的结果是什么?实际看到的错误信息又是什么?

阅读 4.1k
撰写回答
你尚未登录,登录后可以
  • 和开发者交流问题的细节
  • 关注并接收问题和回答的更新提醒
  • 参与内容的编辑和改进,让解决方法与时俱进