watch event deep vuejs code example
Example 1: using the watch method to monitor route updates in vue
export default {
name: 'MovieData',
props: {
movie: {
type: String,
required: true,
}
},
data() {
return {
movieData: {},
}
},
watch: {
movie(movie) {
fetch(`/${movie}`).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!');
}
}
}
}