element-ui 之 表单验证规则
作者:互联网
element-ui 之 表单验证规则
const rules = { role: { type: 'enum', enum: ['admin', 'user', 'guest'] }, data: [{type: 'date', required: true, trigger: 'change', message: "日期不能为空"}], time: [{type: 'array', required: true, trigger: 'change', message: "时间不能为空"}], };
Type
Indicates the type
of validator to use. Recognised type values are:
string
: Must be of typestring
.This is the default type.
number
: Must be of typenumber
.boolean
: Must be of typeboolean
.method
: Must be of typefunction
.regexp
: Must be an instance ofRegExp
or a string that does not generate an exception when creating a newRegExp
.integer
: Must be of typenumber
and an integer.float
: Must be of typenumber
and a floating point number.array
: Must be an array as determined byArray.isArray
.object
: Must be of typeobject
and notArray.isArray
.enum
: Value must exist in theenum
.date
: Value must be valid as determined byDate
url
: Must be of typeurl
.hex
: Must be of typehex
.email
: Must be of typeemail
.any
: Can be any type.
官方地址 async-validator
标签:string,enum,number,表单,ui,array,element,type,Must 来源: https://www.cnblogs.com/dafei4/p/16522512.html