Browse Source

fix: 修复虚拟键盘光标移位退格暴露的问题

master
guoapeng 2 weeks ago
parent
commit
ead2676f0b
  1. 16
      src/components/common/FTInput/index.vue

16
src/components/common/FTInput/index.vue

@ -180,12 +180,18 @@ const ignoreBlur = ref(false)
const handleBackspace = () => {
ignoreBlur.value = true
// const position = keyboard.value.getCaretPosition()
// console.log(position)
const value = model.value?.toString() || ''
model.value = value.slice(0, -1)
const input = model.value?.toString() || ''
let index: number | null
console.log(model.value)
//
const start = keyboard.value.getCaretPosition()
const end = keyboard.value.getCaretPositionEnd()
model.value = input.slice(0, start) + input.slice(end)
// eslint-disable-next-line prefer-const
index = start
//
keyboard.value.setCaretPosition(index)
// blur
setTimeout(() => {
ignoreBlur.value = false

Loading…
Cancel
Save