form表单校验
<form :model="formdata" :rules="rule" :inline="true" ref="formdata"> <el-form-item label="问题" prop="question"> <el-input v-model="fromdata.question"></el-input> </el-form-item> </form> data(){ return { formdata:{question: ""} } } rule:{ question:[{required: true,trigger: 'blur', message: '不能为空'}] question:[{required: true,trigger: 'blur', validator: validatorFuntion}] } validatorFuntion = (rule,value,callback) => { if(!value){ return callback('不能为空') } else { return callback() } }