Answers for "watch nested data vue"

1

vue change deep element

Vue.set(vm.someObject, 'b', 2) //for objects
Vue.set(vm.items, indexOfItem, newValue) //forarrays
Posted by: Guest on December-31-2020
3

vue watch child property

...
watch:{
    'item.someOtherProp'(newVal){
        //to work with changes in "myArray"
    },
    'item.prop'(newVal){
        //to work with changes in prop
    }
}
Posted by: Guest on September-11-2020
0

watch nested data vue

var vm = new Vue({
  el: '#app',
  computed: {
    foo() {
      return this.item.foo;
    }
  },
  watch: {
    foo() {
      console.log('Foo Changed!');
    }
  },
  data: {
    item: {
      foo: 'foo'
    }
  }
})
Posted by: Guest on October-10-2021

Browse Popular Code Answers by Language