vue3 中要在光标所在位置插入字符,可以使用 $refs 和 selectionEnd 属性。
首先,你需要在组件的 template 中给输入框加上一个 ref 属性,例如:
<template>
<input ref="input" />
</template>
vue3 中要在光标所在位置插入字符,可以使用 $refs 和 selectionEnd 属性。
首先,你需要在组件的 template 中给输入框加上一个 ref 属性,例如:
<template>
<input ref="input" />
</template>