vue表单验证的时候提示 async-validator:‘‘ is not a string

Posted 泠泠在路上

tags:

篇首语:本文由小常识网(cha138.com)小编为大家整理,主要介绍了vue表单验证的时候提示 async-validator:‘‘ is not a string相关的知识,希望对你有一定的参考价值。

在前端开发时用到async-validator插件时,莫名其妙报async-validator:’’ is not a string
而且校验也会失效。

造成原因:

1.在方法校验的时候,会有一部分非String类型表单项提示校验未通过
2.尤其是async-validator在无法验证数字格式的表单值得时候,只需要在规则中声明一下类型即可,因为你不加的话,他默认是string

解决方案:

一、去掉:rules 规则中的 trigger 属性

namerules:[{ required: (item.required), message: '请填写' + item.label}]

二、在校验规则里限定type,如果是验证数字格式的,就设为type: 'number’

  group:[{ required: true, type: 'number', message: '请选择分组', trigger: 'change' }]

我在开发中就遇到是数字类型的校验情况,加了type: 'number’就解决了这个问题,不过这问题有点匪夷所思还是找了很久解决方案,特此分享给大家尝试~

以上是关于vue表单验证的时候提示 async-validator:‘‘ is not a string的主要内容,如果未能解决你的问题,请参考以下文章

vue表单验证的时候提示 async-validator:‘‘ is not a string

vue表单验证的时候提示 async-validator:‘‘ is not a string

vue 表单验证 async-validator: ["xxx is not a string"]

Web前端-vue+element表单rules验证(多重object)

Element表单验证

Element表单验证