# 使用 autocomplete="new-password" 阻止自动填充 (opens new window)
autocomplete="new-password"
# 设置输入框光标位置
input.setSelectionRange(start, end):用于设置输入框的光标和文本选区位置。start 是光标的位置,end 是选区的结束位置(通常用于选中文本)。如果 start 和 end 相同,则光标会停在该位置。
// 获取原生input
const input: HTMLInputElement = inputRef.value[0].$el.querySelector('input')
const dotIndex = input.value.lastIndexOf('.')
console.log('dotIndex: ', dotIndex)
if (dotIndex !== -1) {
input.setSelectionRange(dotIndex, dotIndex)
input.focus()
}
1
2
3
4
5
6
7
8
2
3
4
5
6
7
8