watcher in object vue code example
Example 1: using the watch method to monitor route updates in vue
watch: {
movie {
handler: 'fetchData'
},
actor: {
handler: 'fetchData',
}
},
methods: {
fetchData() {
fetch(`/${this.movie}/${this.actor}`).then((data) => {
this.movieData = data;
});
}
}
Example 2: using the watch method to monitor route updates in vue
export default {
name: 'ColourChange',
props: {
colours: {
type: Array,
required: true,
},
},
watch: {
colours: {
deep: true,
handler()
console.log('The list of colours has changed!');
}
}
}
}