表单

在表单验证方面,Vuetify拥有集成了众多的功能,想要使用第三方验证插件?您可以开箱即用Vee-validate和Vuelidate。

用例

The internal v-form component makes it easy to add validation to form inputs. All input components have a rules prop which takes an array of functions. These functions allow you to specify conditions in which the field is valid or invalid. Whenever the value of an input is changed, each function in the array will receive the new value. If a function returns false or a string, validation has failed.

API

v-form
名称
lazy-validation
默认值
false
类型
boolean

如果启用,value将永远是 true ,除非有可见的验证错误。您仍然可以调用validate()来手动触发验证。

名称
value
默认值
false
类型
boolean

控制可见性

示例

Creating rules

Rules allow you to apply custom validation on all form components. These are validated sequentially and will display a maximum of 1 error at a time, so make sure you order your rules accordingly.

VForm - 提交和清除时验证和

验证

Vee-validate

Vee-validate是另一个验证插件,允许您检查您的表单。一个警告是,当您使用value属性时必须添加type="checkbox"来正确验证一个v-checkbox

Edit this page | language on Github
Vuetify 3 is now available!The latest version of Vuetify is now available!
Learn about Vuetify 3's new features and functionality for modern Vue applications
Start exploringExplore