elementui 和vux input只能输入整数,不能小数点

需求:输入框只能输入正整数,不能输入小数,负数

elemntui

<el-input placeholder="请输入对应积分(1-3个字符)" v-model.trim="typeItem.point" type="number" pattern="[0-9]*" :maxlength="3" @keyup.native="proving(typeItem.point,typeIndex)">
</el-input>
vux
<x-input :title="recordItem.typeName" placeholder="请输入数量" v-model.trim="recordItem.typeCount" :max="3" :key="recordItem.typeId" :show-clear="false" @keyup.native="proVing(recordItem.typeCount,recordIndex)"></x-input>
绑定一个事件
proving(item,index){
      item=item.replace(/[^\.\d]/g,''); //这个验证输入正整数
      item=item.replace('.',''); //这个把.换成空
      this.typeJsonArr.forEach((typeItem,itemIndex) => {
        if(itemIndex==index){
          typeItem.point=item;
        }
      });
    },
 
 
 

猜你喜欢

转载自www.cnblogs.com/zhihou/p/10833583.html