标签:name rop type v-model model width ref element blur
在输入框绑定 :required="form.delivery"
<el-form ref="form" :rules="rules" :model="form" label-width="80px">
<el-form-item label="即时配送" class="swi" prop="delivery">
<el-switch v-model="form.delivery"></el-switch>
</el-form-item>
<el-form-item label="即时配送" class="swi" prop="info" :required="form.delivery">
<el-input v-model="form.info"></el-input>
</el-form-item>
<el-button type="primary" @click="onSubmit">立即创建</el-button>
</el-form>
<script>
export default {
name: "Index",
data: () => ({
form:{
delivery:false,
info:"",
},
rules: {
info: [{message: ‘必须填写用户名‘, trigger: ‘blur‘}],
},
}),
}
</script>
vue+Element-ui 如果开关true输入框必填,否则可选
标签:name rop type v-model model width ref element blur
原文地址:https://www.cnblogs.com/dandan9999/p/10996962.html