npm install vee-validate@next --save
import VeeValidate from 'vee-validate' Vue.use(VeeValidate);
<div>
<label for="email">邮箱:</label>
<input v-validate ="'required|email'" type="text" id="email" name="myEmail">
</div>
<span v-show="errors.has('myEmail')">{{ errors.first('myEmail')}}</span>
import zh_CN from 'vee-validate/dist/locale/zh_CN'
import { Validator } from 'vee-validate';
Validator.addLocale(zh_CN);
Vue.use(VeeValidate, {
locale: 'zh_CN',
});
//配置
const config = {
errorBagName: 'errors', // change if property conflicts.
fieldsBagName: 'fields',
delay: 0,
locale: 'zh_CN',
strict: true,
enableAutoClasses: false,
classNames: {
touched: 'touched', // the control has been blurred
untouched: 'untouched', // the control hasn't been blurred
valid: 'valid', // model is valid
invalid: 'invalid', // model is invalid
pristine: 'pristine', // control has not been interacted with
dirty: 'dirty' // control has been interacted with
},
events: 'blur',
inject: true
};
Vue.use(VeeValidate, config);
//修改默认错误提示
const dictionary = {
zh_CN: {
messages: {
email: () => '邮箱格式不正确哦'
}
}
};
Validator.updateDictionary(dictionary);
Validator.extend('qq', {
messages: {
zh_CN:field => 'qq号码输入不正确'
},
validate: value => {
return /^[1-9][0-9]{4,14}$/.test(value);
}
});
机械节能产品生产企业官网模板...
大气智能家居家具装修装饰类企业通用网站模板...
礼品公司网站模板
宽屏简约大气婚纱摄影影楼模板...
蓝白WAP手机综合医院类整站源码(独立后台)...苏ICP备2024110244号-2 苏公网安备32050702011978号 增值电信业务经营许可证编号:苏B2-20251499 | Copyright 2018 - 2025 源码网商城 (www.ymwmall.com) 版权所有