methods: {
async insertAtCursor(item) {
var myValue = '{' + item.strvoucherremarkname + '}'
const myField = this.$refs.textarea.$el.children[0]
if (myField.selectionStart || myField.selectionStart === 0) {
var startPos = myField.selectionStart
var endPos = myField.selectionEnd
this.generateForm.strremark = myField.value.substring(0, startPos) + myValue + myField.value.substring(endPos, myField.value.length)
await this.$nextTick() // 这句是重点, 圈起来,不加的话后面两步有问题
myField.focus()
myField.setSelectionRange(endPos + myValue.length, endPos + myValue.length)
} else {
this.generateForm.strremark += myValue
}
}
}