<u--textarea
autoHeight
v-model="text"
border="none" maxlength="-1" @blur="handleBlur"
/>
const selectionEnd = ref(0)
const text = ref('')
const newText = ref('')
const handleBlur = (e) => {
//光标在第几个字符后面
selectionEnd.value = e.detail.cursor
}
//插入事件
const handleChangeText = () => {
const str = '需要插入的内容'
newText.value = text.value.slice(0, selectionEnd.value) + str + text.value.slice(selectionEnd.value);
}
u--textarea中获取光标位置插入文字
最新推荐文章于 2024-05-14 11:22:04 发布