el-input-number有个坑,设置步长20后,输入44显示40,但是v-model拿到的值却是44,导致传给后台的数据是错的!如何解决? el-input-number v-model="info.cartNum" :step="info.qtyctn" :min="1" :max="9999" @ch
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
}