1export default {
2 name: 'ColourChange',
3 props: {
4 colours: {
5 type: Array,
6 required: true,
7 },
8 },
9 watch: {
10 // Use the object syntax instead of just a method
11 colours: {
12 // This will let Vue know to look inside the array
13 deep: true,
14
15 // We have to move our method to a handler field
16 handler()
17 console.log('The list of colours has changed!');
18 }
19 }
20 }
21}
1watch(
2 colours,
3 () => {
4 console.log('The list of colours has changed!');
5 },
6 {
7 deep: true,
8 }
9);