vue listener base 4

Listener

  Use: Set needs to listen to the data in the attribute name on it

new new Vue ({ 
      EL: "App #" , 
      Data: { 
        COUNT: 0 
      }, 
      Watchers: { 
        COUNT () { 
          //this.count changed  }  }  })

  Listener for asynchronous operation

  Monitor data object properties of an object

     'Count.test' () {// change trigger this.count.test}

  Gets old value:

    'Count.test' (newval, oldval) {console.log (newval, oldval)} wherein newval equal this.count.test

  Depth monitor:

    When listening to an object, is to monitor the entire object, not just a property, such as the count is an object, this.count.test changes, listening to the entire count, then the corresponding listener will not trigger, only whole object is replaced change will only be triggered

    Monitor the entire object is known as the depth monitoring, it is true to turn this feature by setting the deep

watchers:{
        count(newval,oldval){
          console.log(newval,oldval)
        },
        deep:true
      }

Guess you like

Origin www.cnblogs.com/shcs/p/11901781.html