vue elementui rules根据条件判断下一个选项必填和非必填的校验
<el-form-item label="HyperLink" prop="target" :rules="formInfo.type === 1?formRule.target:[{ required: false}]"> <el-input class="form-input" v-model="formInfo.target" clearable size="small" placeholder="Please select related content" @focus="selectArticle"></el-input> </el-form-item>
formRule: {
title: [
{ required: true, message: 'Please enter Banner title', trigger: 'blur' },
{ min: 1, max: 50, message: '1 to 50 characters', trigger: 'blur' }
],
img: [
{ required: true, message: 'Please select a cover image', trigger: 'change' }
],
type: [
{ required: true, message: 'Please select a jump type', trigger: 'change' }
],
target:[
{ required: true, message: 'Please write a content', trigger: 'blur' }
]
},
转自:https://www.bianchengquan.com/article/269073.html