Replies: 3 comments
-
Beta Was this translation helpful? Give feedback.
0 replies
-
I do think this is trivial to do in Vue's API. Say we can write a function to build a map of refs. const fields = reactive({
name: null, email: null, password: null, // ...
})
const refs = toRefs(fields)
for (const inputRef of Object.values(refs)) {
inputRef.value.validate();
} |
Beta Was this translation helpful? Give feedback.
0 replies
-
makes sense and somewhat related to #427 There are other strategies which may be better for this use case though... |
Beta Was this translation helpful? Give feedback.
0 replies
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Uh oh!
There was an error while loading. Please reload this page.
-
In vue options api we have this.$refs which is genial but we don't have it in the composition api.
The problem
Let's go throught following example. I use quasar and I have a form with a lot of fields where each field is referenced. When the form is submitted I want to validate them one after another. So with options api I can just do the following:
simple right ...
and now the same example with current composition api
It's a way more verbose and not flexible.
And imagine now that we have 20 or even more fields.
Possible implementation
const allTemplateRefs = refs() or the more verbose templateRefs() which do the same as this.$refs
Beta Was this translation helpful? Give feedback.
All reactions