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

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;
        }
      });
    },

 

 
 
 
posted on 2019-05-08 18:15  执候  阅读(2409)  评论(0编辑  收藏  举报