<textarea-->
<!-- id="input-id"-->
<!-- class="transparent-input1"-->
<!-- :rows="2"-->
<!-- placeholder="请输入内容,Shift+Enter换行"-->
<!-- v-model="resultShow"-->
<!-- @keydown="handleKeydown"-->
<!-- ></textarea>-->
handleKeydown(event) {
if (event.key === 'Enter' && event.shiftKey) {
// Shift + Enter for newline
const cursorPos = event.target.selectionStart;
this.textarea =
this.textarea.substring(0, cursorPos) + '\n' + this.textarea.substring(cursorPos);
this.$nextTick(() => {
event.target.selectionStart = cursorPos + 1;
event.target.selectionEnd = cursorPos + 1;
});
event.preventDefault();
} else if (event.key === 'Enter' && !event.shiftKey) {
// Enter for submit
this.open();
event.preventDefault();
}
},
标签:target,textarea,换行,enter,shif,cursorPos,Enter,event
From: https://www.cnblogs.com/baozhengrui/p/18457750