例如(用的是IView前端组件、建议使用ElementUI免费的):

<FormItem :label="L('ProductPrice')" prop="price">
            <Input v-model="formModel.price" :maxlength="32"></Input>
          </FormItem>

原因是因为price是number类型的,而校验默认是string,所以要在rules中标明类型

rules = {
    price: [
      {
        required: true,
        message: this.L("FieldIsRequired", undefined, this.L("ProductPrice")),
        trigger: "blur",
        type: "number",
      },
    ]
}

 

posted on 2021-03-05 17:42  邢帅杰  阅读(203)  评论(0编辑  收藏  举报