iview InputNumber类输入框表单验证失效

 <Form ref='form'
            :model="formParams"
            :rules="formRules"
            :label-width="80">
        <FormItem label="排序号"
                  prop="sort">
          <InputNumber style="width:100%;"
                       v-model="formParams.sort"></InputNumber>
        </FormItem>
      </Form>

验证为

formRules: {
        sort: [
          { required: true, message: '排序号不可为空', trigger: 'blur' }
        ]
      }

按上面这种写法,不论输入什么数字,验证都是失败

应改为

formRules: {
        sort: [
          { required: true, message: '排序号不可为空', type: 'number', trigger: 'blur' }
        ]
      }

加上type,在不限制type是默认是‘string’

posted @ 2021-11-08 10:16  忽闻河东狮子吼  阅读(1102)  评论(0编辑  收藏  举报