Vue.js question detail
How to trigger watchers on initialization?
You can use immediate: true option in order to trigger watchers when the vue instance (or component) is being
created. i.e This option will trigger the callback immediately with the current value of the expression.
watch: {
test: {
immediate: true,
handler(newVal, oldVal) {
console.log(newVal, oldVal)
},
},
},