There are multiple times where you need to watch pieces of data within your VueJS component. However, did you know you can watch nested component data with VueJS? Let’s say you are mapping a data to a model that looks like this:
export default {
data(){
return {
form: {
name: '',
dob: '',
job: ''
}
}
}
}
This is a nice way to handle sending data to an API since all you have to do is pass this.form
. However, what if you want to compute values when a piece of the nested data changes or if the whole form changes? Luckily VueJS makes that a breeze. Let’s run through a few examples.