Answers for "Watching Arrays and Objects (Vue 3)"

0

Watching Arrays and Objects (Vue 3)

watch(
  colours,
  () => {
    console.log('The list of colours has changed!');
  },
  {
    deep: true,
  }
);
Posted by: Guest on July-28-2021
0

Watching Arrays and Objects (Vue 2)

export default {
  name: 'ColourChange',
  props: {
    colours: {
      type: Array,
      required: true,
    },
  },
  watch: {
    // Use the object syntax instead of just a method
    colours: {
      // This will let Vue know to look inside the array
      deep: true,

      // We have to move our method to a handler field
      handler()
        console.log('The list of colours has changed!');
      }
    }
  }
}
Posted by: Guest on July-28-2021

Code answers related to "Javascript"

Browse Popular Code Answers by Language