可以将rules
验证写到el-form-item
里面,然后双向绑定required
的值,实现动态控制必填选填
<el-form-item label="备注"
prop="remark"
:rules="[{ required: isRequired, message: '请填写备注', trigger: 'blur' }]">
<el-input type="textarea" :maxlength="10" show-word-limit v-model="remark"></el-input>
</el-form-item>