vue deep watch
snippet in javascript

vue deep watch

user7973

watch: {
    colors: {
        handler(newValue){
            console.log('colors changed', newValue)
        }, deep: true
    }
}

vue watch deep

user3478

export default {
  name: 'ColorChange',
  props: {
    colors: {
      type: Array,
      required: true,
    },
  },
  watch: {
    colors: {
      // This will let Vue know to look inside the array
      deep: true,

      // We have to move our method to a handler field
      handler(value) {
        console.log('The list of colors has changed!', value);
      }
    }
  }
}