el-form-item 绑定数组做校验
2022-12-29 17:14:14
2024-11-21 18:11:36
language
<el-form-item
label="项目:"
v-if="formData.educTypeId !== 3"
prop="projectId"
:class="{ echoColor: projectId.length > 0 }"
:rules="[
{
validator: (rule, value, callback) => {
projectIdCheckClass(
rule,
value,
callback,
projectId
);
},
message: '项目不能为空',
trigger: 'change',
required: true
}
]"
>
language
## methods方法写
projectIdCheckClass(rule, values, callback, data) {
//自定义验证的逻辑
if (!this.projectId || !this.projectId.length) {
return callback(new Error(`项目不能为空`));
} else {
return callback();
}
},
目录