提交 19434520 编写于 作者: D DCloud_LXH

fix: 修复 input设置type=number和maxlength时,光标移至中间可输入且值不同步问题

上级 4772e7d5
......@@ -188,10 +188,15 @@ export default {
if (this.inputType === 'number') {
const maxlength = parseInt(this.maxlength, 10)
if (maxlength > 0 && $event.target.value.length > maxlength) {
$event.target.value = $event.target.value.slice(0, maxlength)
this.valueSync = $event.target.value
// 字符长度超出范围不触发 input 事件
outOfMaxlength = true
// 输入前字符长度超出范围,则不触发input,且将值还原
// 否则截取一定长度且触发input
if (this.cachedValue.length === maxlength) {
this.valueSync = this.cachedValue
outOfMaxlength = true
} else {
$event.target.value = $event.target.value.slice(0, maxlength)
this.valueSync = $event.target.value
}
}
}
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册