vuejs vee-validate: this.error.add -> 从字典中添加消息

vuejs vee-validate: this.error.add -> add message from dictionary

我有一个简单的登录表单,如果用户使用了错误的密码或用户名,我会显示一条消息

js

onSignin() {
    axios.post(
        'api/user/signin',
        {
            email: this.email,
            password: this.password,
        },
        {
            headers: { 'X-Requested-With': 'XMLHttpRequest' },
        },
    ).then((response) => {
            this.$router.push('dashboard');
        }).catch((error) => {
            this.errors.add('credentials', 'Wrong user or Password'); //this message i want to move to the dictionary
        });
    },

html

<form action="POST" >
    <span v-show="errors.has('credentials')" class="help is-danger">{{ errors.first('credentials') }}</span>
    <p class="form-group">
    ...

这有效,会显示错误消息,但我如何将此消息添加到字典中,以便我将所有消息集中在一个地方?

我在那里得到了答案;)

https://github.com/baianat/vee-validate/issues/963

Validator.dictionary.merge({
    en: {
        messages: {
          credentials: 'Wrong user or password'
    }
  }
});

const message = this.$validator.dictionary.getMessage('en', 'credentials');
this.errors.add('credentials', message); //this message i want to move to the dictionary