veevalidate配置 import Vue from 'vue' import VeeValidate from 'vee-validate'; //修改语言包 import zh_CN from 'vee-validate/dist/locale/zh_CN'; //自定义规则 //import Validator from './assets/js/customValidate'; //VeeValidate语言包切换,放自定义提示前 Validator.addLocale(zh_CN); //自定义提示 const dictionary = { zh_CN: { messages: { required: () => '不能为空', ip:()=>'请输入有效的IP地址', email:()=>'请输入正确格式的邮箱', } } }; Validator.updateDictionary(dictionary); //customValidate.js import { Validator } from 'vee-validate'; Validator.extend('mobile', { messages: { zh_CN:field => '手机号码输入不正确', }, validate: value => { return value.length == 11 && /^((13|14|15|17|18)[0-9]{1}\d{8})$/.test(value) } }); //export default Validator; //载入 Vue.use(VeeValidate, { locale: 'zh_CN', });