1.prop=对象
<FormItem label="身高:" :label-width="80" prop="shapeDifference.heightSpaceT2"> <Input v-model="formItem.shapeDifference.heightSpaceT2" placeholder="请保留两位小数" ></Input> </FormItem>
2.校验
'shapeDifference.heightSpaceT2':[ { validator: validateheightSpaceT2, trigger: 'blur' }, ],
3.规则:
const validateheightSpaceT2 = (rule, value, callback) => { console.log(23142) console.log(value) var reg=/(^[1-9]{1}[0-9]*$)|(^[0-9]*\.[0-9]{2}$)/ if (!value) { return callback(new Error('不能为空')); }else if(!reg.test(value)) { callback(new Error('请输入一个整数或者保留小数点后两位')); }else { callback(); } };