Welcome to OStack Knowledge Sharing Community for programmer and developer-Open, Learning and Share
Welcome To Ask or Share your Answers For Others

Categories

0 votes
515 views
in Technique[技术] by (71.8m points)

vuetify.js - Vuetify - validate programmatically added field values

I have seen the examples for a v-form here.(https://vuetifyjs.com/en/components/forms/).

They work as expected and produce error messages when a user inputs an invalid value.

I do not see how to validate programmatically. Below is a bare-bones example.

 <v-form v-model="valid" ref="form">
   <v-text-field v-model="foo" :rules="someRules" label="Test Field"/>
   <v-btn @clicked="changeValue">Change Value</v-btn>
 </v-form>
 ...
 changeValue() {
  this.foo = "somethingInvalid";
  // this.$refs.form.validate();
 }

If the user typed something invalid into the v-text-field a validation error would be shown (as expected). However if it is done via the changeValue() call the validation error is not shown.

I have also tried the forms validate() method, but it doesn't seem to do anything.

question from:https://stackoverflow.com/questions/65600937/vuetify-validate-programmatically-added-field-values

与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
Welcome To Ask or Share your Answers For Others

1 Answer

0 votes
by (71.8m points)
Waitting for answers

与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
Welcome to OStack Knowledge Sharing Community for programmer and developer-Open, Learning and Share
Click Here to Ask a Question

...