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()
    }
}

 

posted @ 2020-05-12 17:16  不服憋着  阅读(289)  评论(0编辑  收藏  举报