deadsimple / vuelidatelibrary
一个简单的模块,用于在您的现代 Magento 2 Vue 项目中使用 Vuelidate
1.0.2
2020-09-30 13:03 UTC
Requires
- deadsimple/vuelibrary: >=1.0
- magento/framework: >=100.1.0
This package is auto-updated.
Last update: 2024-09-29 05:36:24 UTC
README
Deadsimple Vuelidate Magento2 Composer Library
使用 vuelidate 在您的 Magento 2 VueJS 表单中实现现代表单验证
安装
使用 composer 安装模块: composer require deadsimple/vuelidatelibrary
使用方法
要使用 Vuelidate,您需要使用 Magento 2 requirejs 方法加载 Vuelidate 库及其 Validators。选择必要的混入和您想要使用的验证器,并使用解构语法。像其他混入一样加载混入,然后按照其 文档 中所述使用 Vuelidate。
define([
'Vue',
'Vuelidate',
'VuelidateValidators',
], function (Vue, Vuelidate, validators) {
const {validationMixin} = Vuelidate;
const {required, email } = validators;
Vue.component('contactForm', {
template: template,
mixins: [ validationMixin ],
data() {
return {
name: null,
email: null,
}
},
validations(){
name: { required },
email: { required, email }
}
})
})
版本
此库加载: Vuelidate v0.7.5