veeValidate

Posted 浪迹灬天涯

tags:

篇首语:本文由小常识网(cha138.com)小编为大家整理,主要介绍了veeValidate相关的知识,希望对你有一定的参考价值。

网站

http://vee-validate.logaretm.com/index.html#about

 

自定义为空时候的提示

Field-specific Custom Messages

You might need to provide different messages for different fields, for example you might want to display an error message for the email field when its required, but a different messsage when the name is required. This allows you to give your users a flexible experience and context aware messages.

To do this you would need to add an object to the dictionary called custom like this:

const dict = {
  en: {
    custom: {
      email: {
        required: ‘Your email is empty‘ // messages can be strings as well.
      },
      name: {
        required: () => ‘Your name is empty‘
      }
    }
  }
};

Notice that the custom object contains properties that represent the field names, those field names objects contain properties that represent the validation rule that its value will be used instead of the default one.

Then you would need to add the dictionary we just constructed to the current validators dictionary like this:

Validator.updateDictionary(dict);
// or use the instance method
this.$validator.updateDictionary(dict);

以上是关于veeValidate的主要内容,如果未能解决你的问题,请参考以下文章

veeValidate使用data-vv-scope实现部分区域校验以及清空errors

VeeValidate3:自定义验证在提交时始终为真

Vuetify DateTime Picker 和 VeeValidate 问题

如何使用 VeeValidate 验证来自 BootstrapVue 表单的输入?

即使使用密钥,VeeValidate 也会验证不存在的字段错误

veeValidate