提交 a2a72300 编写于 作者: D DCloud_LXH

fix: 修复 input 组件类型为 number 时在低版本 webview 失去焦点时报错的问题 question/138088

上级 c19ecdd0
......@@ -314,7 +314,8 @@ function useEvent(
field &&
state.focus &&
state.selectionStart > -1 &&
state.selectionEnd > -1
state.selectionEnd > -1 &&
field.type !== 'number'
) {
field.selectionStart = state.selectionStart
field.selectionEnd = state.selectionEnd
......@@ -327,7 +328,8 @@ function useEvent(
state.focus &&
state.selectionStart < 0 &&
state.selectionEnd < 0 &&
state.cursor > -1
state.cursor > -1 &&
field.type !== 'number'
) {
field.selectionEnd = field.selectionStart = state.cursor
}
......@@ -370,9 +372,18 @@ function useEvent(
onInput(event, true)
}
state.focus = false
const field = event.target! as HTMLInputElement
let cursor
if (field.type === 'number') {
field.type = 'text'
cursor = field.selectionEnd
field.type = 'number'
} else {
cursor = field.selectionEnd
}
trigger('blur', event, {
value: state.value,
cursor: (event.target as HTMLFieldElement).selectionEnd,
cursor,
})
}
// 避免触发父组件 change 事件
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册