1.)监听变量普通

data(){
     return {
           input:'',        
      }  
},
watch:{
     input(val,oldVal){
    }
}

2.)深度监听

watch:{
     'input':{
           handler: function(val, oldVal){
    
           }
     },
     deep: true,
     immediate: true,
}        

3.) 深度监听vux

watch: {
     '$store.getters.user':{
          handler: function(val, oldVal){
           } 
     },
      deep: true,
      immediate: true,
}

4.) 深度监听vux方法二

computed:{
     listenUser(){
          return this.$store.getters.user;
     }
},
watch: {
      listenUser:{
           handler: function(val, oldVal){
           }
      }
}

5.) 深度监听路由

watch: {
     '$route.path':{
          handler: function(val, oldVal){
           } 
     },
      deep: true,
      immediate: true,
}

  

 

相关文章:

  • 2022-12-23
  • 2021-12-20
  • 2021-10-16
  • 2022-12-23
  • 2022-12-23
  • 2022-12-23
  • 2022-12-23
  • 2022-12-23
猜你喜欢
  • 2021-10-21
  • 2021-08-21
  • 2021-07-10
  • 2022-12-23
  • 2022-12-23
  • 2022-12-23
  • 2022-12-23
相关资源
相似解决方案