element ui 表单校验,非必填字段校验 All In One
没有 props 无法校验 bug
<el-form-item
class="not-required" label="副标题" key="subtitle"
:rules="[
{
required: false,
// message: '请输入副标题',
trigger: ['change'],
// trigger: ['blur', 'change'],
validator: validateSubtitle,
},
]">
<el-input
style=" 300px;"
placeholder="4-24个字符,中文占两个字符"
v-model="ruleForm.subtitle"
@change="subtitleChange"
/>
</el-form-item>
required: false, 不好使
<el-form-item
class="not-required" label="副标题" prop="subtitle" key="subtitle"
:rules="[
{
required: false,
// message: '请输入副标题',
trigger: ['change'],
// trigger: ['blur', 'change'],
validator: validateSubtitle,
},
]">
<el-input
style=" 300px;"
placeholder="4-24个字符,中文占两个字符"
v-model="ruleForm.subtitle"
@change="subtitleChange"
/>
</el-form-item>
refs
©xgqfrms 2012-2020
www.cnblogs.com/xgqfrms 发布文章使用:只允许注册用户才可以访问!
原创文章,版权所有©️xgqfrms, 禁止转载 ️,侵权必究⚠️!