緣由因爲vee-validate版本更新的問題致使的。html
1. 緣由分析:node
a 新版vee-validate的語言配置方法變化了, Validator.localize('zh_CN', zh_CN)ui
第一個參數是dictionary的定義語言的方法名,例以下圖的‘zh_CN' ; 第二個參數是引用的語言js, 本文中是中文,引自node_modules下的vee-validate/dist/locale/zh_CN.js.spa
參見官網地址: http://vee-validate.logaretm.com/localization.html#localized-fileshtm
b. 自定義規則的.extend()方法變化blog
e.g.:Validator.extend('truthy', { getMessage: field => 'The ' + field + ' value is not truthy.', validate: value => !! value });get
注意:兩個方法的使用:io
getMessage(field, args) {class
// will be added to default English messages.module
// Returns a message.
},
validate(value, args) {
// Returns a Boolean or a Promise.
}
參見官網地址:http://vee-validate.logaretm.com/validation.html#custom-rules
2. 解決方法以下截圖:
validate,js
自定義規則, customValidate,js