listen for on change vue code example
Example 1: how to watch for changes within a prop in vue
watch: {
$props: {
handler() {
this.parseData();
},
deep: true,
immediate: true,
},
Example 2: v-on:change vue
// It is important that the watch function be named the same as the data/computed property.
new Vue({
computed: {
parsedInput () {
return parse(this.userInput)
}
},
methods: {
process () {
serverProcess(this.parsedInput);
},
},
watch: {
parsedInput() {
this.process()
}
}
})