ant design vue表单控件使用v-decorator进行表单校验
v-decorator="['je',{rules: [{required: true,validator:verifyJE }] },]"//校验方法verifyJE(rule, value, callback){let curValue=Number(value)curValue=curValue.toFixed(2)let yfValue=this.form.getFieldValue('zyfje')||'无'let reg=/(^[1-9]{1}[0-9]*$)|(^[0-9]*\.[0-9]{2}$)/let lengthCheck=falselet dotCheck=falseif(value.indexOf('.')!=-1){if(value.split('.')[1].length>2){lengthCheck=true //判断小数位数}else if(value.split('.')[1].length==0){dotCheck=true //判断整数后输入点(.)的情况如(12.)}}if(curValue>yfValue){callback('金额大于该商品款项应付金额!')}else if(value===''){callback('请输入已支付金额')}else if(!reg.test(value)){callback('禁止输入汉字和特殊字符')}else if(yfValue==='无'){callback('未获取该款项应付金额!')}else if(lengthCheck){callback('小数位数超出两位')}else if(dotCheck){callback('小数位为空')}else{callback()}},