1,在data中定义校验规则变量如图:

elementui如何自定义表单校验规则(rules)?_js

let checkDetailTable = (rule, value, callback) => {
if (this.detailTable.length < 1) {
return callback(new Error('详情页字段不能为空'));
} else {
callback();
}
};

2,在对应的rules中定义prop属性进行校验

elementui如何自定义表单校验规则(rules)?_vue_02

detailTable: [
{
validator: checkDetailTable,
trigger: 'blur'
}
],

完成!!!