Vee validate 4 with options API question #3544
Replies: 4 comments 6 replies
-
I migrated this as a discussion because this is the proper section for it. Please try to keep issues reporting for actual issues. The examples actually use the options API as much as possible, only the Which example are you referring to specifically? You can use the data with |
Beta Was this translation helpful? Give feedback.
-
It will be roughly the same but replace <template>
<Form ref="form">
<Field name="field" rules="email|required" v-model="email" v-slot="{ errors, field }">
<my-custom-component v-bind="field"></my-custom-component>
<span>{{ errors[0] }}</span>
</Field>
<a @click="validate">Do someting</a>
</Form>
</template>
<script>
import { Field, Form } from 'vee-validate';
export default {
components: {
Field,
Form,
},
data: () => ({
email: ''
}),
methods: {
validate: async function () {
const result = await this.$refs.form.validate();
if (result.isValid) {
// do something here
}
},
otherMethod: function() {
// use this.email here for other purposes
},
load: async function() {
this.email = '....'
}
}
};
</script> |
Beta Was this translation helpful? Give feedback.
-
I also stuck with issue of not having Options API documentation. It would be nice to add it. Vue 3 is not only Composition API, all the Vue 2 projects build are on Options API and most of people are not rewriting this to Compositions API. |
Beta Was this translation helpful? Give feedback.
-
this as an example of v-checkbox that work vee-validate 4 with vuetify 3 |
Beta Was this translation helpful? Give feedback.
-
Since the composition API in vue 3 is optional I am still using the options api with the data. I cannot find in the documentation if I cat still easily use vee validate to be bound directly with the data varialbes as in the vee-validate v3 ? As I can see in the docs, everywhere is used setup() with initial state variable, but since I do not use setup, I need to somehow bound initial state to the data variables without changing the data itself. Thank you.
Beta Was this translation helpful? Give feedback.
All reactions