我们发现这样写,cursor的值是不会自动变的

<textarea :cursor="cursor"  />

如果要满足需求的话,这样写就好

    <textarea @blur="handleTextareaBlur"  />
	handleTextareaBlur(e) {
		console.log(e.detail.cursor)
	},

如果你要在某个字符串后面插入一个字符的话

const text = ref('')
const micInput = (str) => {
	if (cursor === 0) {
			text.value += str
	} else {
		    text.value = text.value.slice(0, cursor) + str + text.value.slice(cursor);
	}
}
Logo

欢迎加入DeepSeek 技术社区。在这里,你可以找到志同道合的朋友,共同探索AI技术的奥秘。

更多推荐