1 watch: {
2     $route(to, from) {
3         console.log(to, from)
4     }
5 }
1 watch: {
2     $route: {
3         handler: function(val,oldVal) {
4             console.log(val, oldVal);
5         },
6         // 深度监听
7         deep: true
8     }
9 }
1 watch: {
2     '$route': 'getPath' // 当路由发生变化时执行此函数
3 },
4 methods: {
5     getPath() {
6         console.log(this.$route);
7     }
8 }

 

相关文章:

  • 2022-12-23
  • 2022-12-23
  • 2022-12-23
  • 2022-12-23
  • 2022-12-23
  • 2022-12-23
  • 2022-12-23
猜你喜欢
  • 2021-06-17
  • 2021-08-22
相关资源
相似解决方案