Watching Arrays and Objects (Vue 3)
watch(
colours,
() => {
console.log('The list of colours has changed!');
},
{
deep: true,
}
);
Watching Arrays and Objects (Vue 3)
watch(
colours,
() => {
console.log('The list of colours has changed!');
},
{
deep: true,
}
);
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!');
}
}
}
}
Copyright © 2021 Codeinu
Forgot your account's password or having trouble logging into your Account? Don't worry, we'll help you to get back your account. Enter your email address and we'll send you a recovery link to reset your password. If you are experiencing problems resetting your password contact us