Vee-validate 自定义后显示 “The 账号 value is not valid”
也没有报错,但是显示奇怪的提示。看得出来name是已经被替换成账号了
自定义的index相关内容应该是也没问题的吧
把这个问题涉及的几个文件贴上
main.js
import Vue from 'vue'
import App from './App.vue'
import router from './router'
import store from './store'
import VeeValidate, { Validator } from 'vee-validate'
// import zh from 'vee-validate/dist/locale/zh_CN'
import './local/index'
Vue.use(VeeValidate)
// Validator.localize('zh-CN', zh)
const validator = new Validator()
validator.localize('zh-CN')
Vue.config.productionTip = false
new Vue({
router,
store,
render: h => h(App)
}).$mount('#app')
src/local/index.js
import { Validator } from 'vee-validate'
const dictionary = {
'zh-CN': {
message: {
required: field => '请输入' + field,
email: () => '请输入正确的邮箱格式'
},
attributes: {
email: '邮箱',
password: '密码',
name: '账号'
}
}
}
Validator.localize(dictionary)
package.json
{
"name": "front",
"version": "0.1.0",
"private": true,
"scripts": {
"serve": "vue-cli-service serve",
"build": "vue-cli-service build",
"lint": "vue-cli-service lint"
},
"dependencies": {
"axios": "^0.21.1",
"core-js": "^3.6.5",
"svg-captcha": "^1.4.0",
"vee-validate": "^2.2.13",
"vue": "^2.6.11",
"vue-router": "^3.2.0",
"vuex": "^3.4.0"
},
"devDependencies": {
"@vue/cli-plugin-babel": "~4.5.0",
"@vue/cli-plugin-eslint": "~4.5.0",
"@vue/cli-plugin-router": "~4.5.0",
"@vue/cli-plugin-vuex": "~4.5.0",
"@vue/cli-service": "~4.5.0",
"@vue/eslint-config-standard": "^5.1.2",
"babel-eslint": "^10.1.0",
"eslint": "^6.7.2",
"eslint-plugin-import": "^2.20.2",
"eslint-plugin-node": "^11.1.0",
"eslint-plugin-promise": "^4.2.1",
"eslint-plugin-standard": "^4.0.0",
"eslint-plugin-vue": "^6.2.2",
"sass": "^1.26.5",
"sass-loader": "^8.0.2",
"vue-template-compiler": "^2.6.11"
}
}
谢谢!
12
收起
正在回答
1回答
上面的设置message的问题,你只是替换了attribute,并没有替换Message,可以参考:https://vee-validate.logaretm.com/v2/guide/messages.html#overwriting-messages
来替换message
恭喜解决一个难题,获得1积分~
来为老师/同学的回答评分吧
0 星