element ui表单动态验证规则
作者:互联网
话不多说,先来效果图:
要求是选择延期时,延期天数必填。
<el-form-item label="是否延期" prop="status">
<el-switch
v-model="addForm.status"
active-color="#13ce66"
active-text="是"
inactive-text="否"
active-value="1"
inactive-value="0"
></el-switch>
</el-form-item>
<el-form-item label="延期天数" prop="delay" :rules="addForm.status == 1 ? rules.delay : []">
<el-input type="number" v-model="addForm.delay" placeholder="请输入延期天数"></el-input>
</el-form-item>
/***************************************************/
rules: {
delay: [{ required: true, message: "请输入延期天数", trigger: "blur" }],
}
还有一种方法可以用
<el-form-item label="延期天数" prop="delay" :required="addForm.status == 1 ? true : false">
<el-input type="number" v-model="addForm.delay" placeholder="请输入延期天数"></el-input>
</el-form-item>
敢敢单单, 套你猴子。。。
标签:必填,天数,表单,delay,ui,message,element,延期 来源: https://blog.csdn.net/qq_42816550/article/details/100165824