element ui 表单校验,非必填字段校验 All In One
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="width: 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="width: 300px;"
placeholder="4-24个字符,中文占两个字符"
v-model="ruleForm.subtitle"
@change="subtitleChange"
/>
</el-form-item>
refs
©xgqfrms 2012-2020
www.cnblogs.com/xgqfrms 发布文章使用:只允许注册用户才可以访问!
原创文章,版权所有©️xgqfrms, 禁止转载 🈲️,侵权必究⚠️!
本文首发于博客园,作者:xgqfrms,原文链接:https://www.cnblogs.com/xgqfrms/p/15607860.html
未经授权禁止转载,违者必究!