记一个iview回填数字后,判空校验有问题的小坑

页面表单
<i-form ref="formValidate" :model="d" :rules="ruleValidate" :label-width="88">

<Form-item label="价格" prop="price">
    <i-input v-model="d.price" type="float" placeholder="价格"></i-input>
</Form-item>

js校验修改前

//新增、修改的校验规则
ruleValidate: {
    price: [ {required: true,   message: '价格不能为空', trigger: 'blur'} ,
                   {validator: validatePositiveTwoPointNum, trigger: 'change'},
    ],

},

出现问题点:修改操作时表单回填数据,点击保存,校验提示    “价格不能为空”,但断点数据是有的,且数据回填到了输入框,就校验不通过

js校验修改后校验OK

添加type:'float',

//新增、修改的校验规则
ruleValidate: {
    price: [ {required: true, type:'float',message: '价格不能为空', trigger: 'blur'} ,
                   {validator: validatePositiveTwoPointNum, trigger: 'change'},
    ],

},

数字的判空校验,这里必须注明数字类型