VeeValidate本土化“属性‘区域设置’上输入‘验证’不存在”。

问题描述:

我使用VeeValidate并完全适用于英语(这是默认值) 但是如果我尝试使用我收到一个错误说 任何其他语言的“属性‘区域设置’不上键入‘验证’存在。”VeeValidate本土化“属性‘区域设置’上输入‘验证’不存在”。

这里是我的代码:

import VeeValidate from 'vee-validate'; 
import french from 'vee-validate/dist/locale/fr'; 

Vue.use(VeeValidate); 

@Component 
export default class TestTest extends Vue { 
locale: any; // I have tried locale: string='fr'; 

nextLocale() { 
    return this.locale === 'en' ? 'French' : 'English'; 
} 

changeLocale() { 
    this.locale = this.$validator.locale === 'fr' ? 'en' : 'fr'; 
    this.$validator.setLocale(this.locale); 
}  

created() { 
    this.$validator.updateDictionary({ 
    fr: { 
    messages: french.messages, 
    } 
}) 
} 

// other none related code... 

} 
+1

在我看来,它是在[最新版本的类型]中定义的(https://github.com/baianat/vee-validate/blob/b916e2a28b7c4126fe26312babbc22e412a8c384/types/vee-validate.d.ts#L67.json )。你使用不同的版本? – Bert

+0

刚刚更新到最新版本,还是一样... @Bert – misshomme

据:
http://vee-validate.logaretm.com/localization.html#api

动态改变的语言环境中的组件,你必须调用本地化,像这样

this.$validator.localize('fr', french) 

而且它应该只是正常工作(你不需要调用updateDictionary作为呼叫上面已经这样做了)