1、定义ref值和onblur函数
<el-input type="textarea" ref="inputRef" @blur="inputBlur" autosize v-model="measureDataForm.measuresDesc" placeholder="请输入措施描述" clearable :style='{"width":"74%"}'>
</el-input>
2、获取光标函数
//获取光标
inputBlur() {
this.textCursor = this.$refs.inputRef.$el.children[0].selectionStart;
},
//新增括号按钮
handleAddField() {
if(this.measureDataForm.measuresDesc[this.textCursor]!=undefined){
this.measureDataForm.measuresDesc = this.measureDataForm.measuresDesc.slice(0,this.textCursor) + '( )' + this.measureDataForm.measuresDesc.slice(this.textCursor)
}
}