Is is possible to "watch" for changes when using the form helper? Is this possible? I'm using watch(form.type, (value) => ..... but it's not pickung up on any changes because at face value, form.type is not a ref.
Can't find anything in the documenation about it, so I'm wondering if this is a thing right now.
Hi, have you found a solutions for this?
@tykus This does not work unfortunately
In the end I simply used a @change handler on the select I wanted to watch.
@normykinz That's a shame. I have the exact same problem but my form is quite big and adding a @change event to every form element does not sound ideal.
I found that this seems to work:
watch(
() => form.exampleField,
(exampleField, prevExampleField) => {
/* ... */
}
)
More info: vuejs.org api reactivity-core.html#watch
watching the form.isDirty flag works for detecting the first change to a form:
watch(
()=>form.isDirty,
() => {
//react to first changes
})
})
You can't watch a reactive object directly, you need to use a reactive getter.
This worked for me:
watch(
() => form,
() => {
something();
},
{ deep: true },
);
Please sign in or create an account to participate in this conversation.