<el-form-item label="开始积分" prop="startScore"> <el-input type="number" max="5" min="0" @input="numberChange(arguments[0],5)" @change="numberChange(arguments[0],5)" v-model="queryParams.startScore" placeholder="请输入开始积分" clearable size="small" /> </el-form-item> numberChange (val,maxNum) { //转换数字类型 this.queryParams.startScore = Number(val) //重新渲染 this.$nextTick(()=>{ //比较输入的值和最大值,返回小的 let num = Math.min(Number(val),maxNum) //输入负值的情况下, = 0(可根据实际需求更该) if(num<0) { this.queryParams.startScore = 0 }else { //反之 this.queryParams.startScore = num } }) },
标签:maxNum,val,最大值,Number,输入框,最小值,num From: https://www.cnblogs.com/qiangyanhuanxiao/p/16866161.html