el-input-number步长设置后,手输和显示不一致问题
作者:互联网
el-input-number有个坑,设置步长20后,输入44显示40,但是v-model拿到的值却是44,导致传给后台的数据是错的!如何解决?
<el-input-number v-model="info.cartNum" :step="info.qtyctn" :min="1" :max="9999" @change="changeCartNum(info)"></el-input-number> changeCartNum(info) { const para = {} if(info.qtyctn){ if(info.cartNum % info.qtyctn === 0){//整除 para['cartNum'] = info.cartNum }else{ var count=Math.floor(info.cartNum/info.qtyctn)//取整数 var surplus=info.cartNum % info.qtyctn//余数 if(surplus<info.qtyctn/2){ para['cartNum'] = count*info.qtyctn; }else{ para['cartNum'] = (count+1)*info.qtyctn; } } }else{ para['cartNum'] = info.cartNum }
标签:info,el,cartNum,qtyctn,number,步长,surplus 来源: https://www.cnblogs.com/onesea/p/15701376.html