Element自定义表单rules规则
程序员文章站
2022-07-14 08:48:57
...
data() {
var validateSplitNum = (rule, value, callback) => {
if (value < 1) {
callback(new Error("请输入大于零的正整数"));
} else {
callback();
}
};
return {
rules: {
splitNum: [
{ required: true, message: "工位信息不能为空", trigger: "blur" },
{
pattern: /^[0-9]+$/,
message: "请输入正整数",
trigger: "blur",
},
{
validator: validateSplitNum,
trigger: "blur",
},
],
},
};
},