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的主要内容,如果未能解决你的问题,请参考以下文章

我可以将 async/await Promises 与可观察的 RXJS 混合使用吗?

微信小程序代码片段

VSCode自定义代码片段——CSS选择器

谷歌浏览器调试jsp 引入代码片段,如何调试代码片段中的js

片段和活动之间的核心区别是啥?哪些代码可以写成片段?

VSCode自定义代码片段——.vue文件的模板