<div style="background-color: #efefef; width:100%;height: 300px;"> <textarea ref="contentArea" v-model="contentFormula" style="width: 100%;height: 100%"> {{contentFormula}} </textarea> </div>
const myField = this.$refs.contentArea; if (myField.selectionStart || myField.selectionStart === 0) { let startPos = myField.selectionStart; let endPos = myField.selectionEnd; this.contentFormula = myField.value.substring(0, startPos) + value + myField.value.substring(endPos, myField.value.length); this.$nextTick(()=>{ myField.focus(); myField.setSelectionRange(endPos + value.length, endPos + value.length) }) } else { this.contentFormula += value }