3👍
To watch data changes using the watch
object, add a function to that object with a name matching the data property to watch. For instance, to watch a data property named "question"
, add this function:
watch: {
question(newValue, oldValue) {
//...
}
}
Alternatively, you could add an object named after the target data property, with a handler
function and additional watcher options: deep
and immediate
.
watch: {
question: {
deep: true, // detecting nested changes in objects
immediate: true, // triggering the handler immediately with the current value
handler(newValue, oldValue) {
//...
}
}
}
In your case with "timeRange"
, the syntax would be:
watch: {
timeRange(newValue) {
//...
}
}
- [Vuejs]-Moment.js returning incorect seconds for datetime datetime
- [Vuejs]-Vue should I stop hard coding endpoints in .env?
Source:stackexchange.com