允许在文本框光标的位置插入内容
<div>
<a-textarea ref="textarea" v-model="calcValue" placeholder="请输入计算公式" :auto-size="{ minRows: 5, maxRows: 10 }" @change="inputValue"/>
</div>
insert_Text(insertText){
const textarea = this.$refs.textarea.$el;
const { selectionStart, selectionEnd } = textarea;
// Insert text at cursor position
const newText = this.calcValue.slice(0, selectionStart) + insertText +
this.calcValue.slice(selectionEnd);
// Update text and set cursor position
this.calcValue = newText;
this.$nextTick(() => {
textarea.selectionStart = textarea.selectionEnd = selectionStart + insertText.length;
textarea.focus();
});
},