复制代码
单独使用的多选组件 值{ {formValidate.multiple$1}} 组合使用的多选组件多选的值{ {formValidate.multiple$2.toString()}} 选项 1 选项 2 选项 3
验证规则:
data() { const validateMultiple = (rule, value, callback) => { if (value.length<2) { return callback(new Error('不少于两项')); }else { callback(); } }; return { formValidate: { name: '', email: '', multiple$1: '5', multiple$2: ['option1', 'option2'], }, ruleValidate:{ name:[ {required:true,message:'用户名不能为空', trigger: 'blur'} ], email: [ {required: true, message: '邮箱不能为空', trigger: 'blur'}, { type: 'email', message: "邮箱格式不正确", trigger: 'blur'} ], multiple$2: [ {validator:validateMultiple, trigger: 'change'} ] }, } },复制代码