提交 029e0896 编写于 作者: D DCloud_LXH

fix: ios 16 input type=digit decimal point question/154584

上级 04af4e76
......@@ -87,6 +87,31 @@ export default /*#__PURE__*/ defineBuiltInComponent({
input.addEventListener('blur', resetCache)
return false
}
// 处理小数点
if (cache.value) {
if (cache.value.indexOf('.') !== -1) {
// 删除到小数点时
if (
(event as InputEvent).data !== '.' &&
(event as InputEvent).inputType === 'deleteContentBackward'
) {
const dotIndex = cache.value.indexOf('.')
cache.value =
input.value =
state.value =
cache.value.slice(0, dotIndex)
return true
}
} else if ((event as InputEvent).data === '.') {
// 输入小数点时
cache.value += '.'
resetCache = () => {
cache.value = input.value = cache.value.slice(0, -1)
}
input.addEventListener('blur', resetCache)
return false
}
}
cache.value =
state.value =
input.value =
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册