[Vuejs]-How to watch object in vue js?

0👍

Please consider this code example.

  1. Vue watch child property

    watch:{
    ‘item.someOtherProp'(newVal){
    //to work with changes in "myArray"
    },
    ‘item.prop'(newVal){
    //to work with changes in prop
    }
    }

  2. Vue watch object member

    watch: {
    item: {
    handler(val){
    // do stuff
    },
    deep: true
    }
    }

Also please consider this reference.https://vuejs.org/v2/api/#watch. You can deeply watch objects for changes.

Leave a comment