price:[{ type: 'string', pattern: '^[+]{0,1}(\\d+)$|^[+]{0,1}(\\d+\\.\\d+)$',required: true, message: '此项不能为空且只能输入非负数,请检查', trigger: 'blur' }],
learnUserNum:[{ type: 'string', pattern: '^[+]{0,1}(\\d+)$',required: true, message: '此项不能为空且只能输入正整数(包括0),请检查', trigger: 'blur' }],
name:[{ required: true, trigger: 'blur', validator: validateName }],
const validateName = (rule, value, callback) => {
if (value.length > 20) {
callback(new Error('名字长度不能超过6'))
} else {
callback()
}
}
数据转换校验
for (const v of this.list){
v.lessonNum=v.lessonNum.toString()
v.originalPrice=v.originalPrice.toString()
}