textarea实现回车发送,ctrl+enter换行

html:

        <el-input
          type="textarea"
          autofocus="true"
          @keydown.native="handleKeyCode($event)"
          resize="none"
          v-model="messageTxt"
          maxlength="2000"
          show-word-limit
        >
        </el-input>

js:

// 键盘回车事件
    handleKeyCode(event) {
      if (event.keyCode == 13) {
        if (!event.metaKey) {
          event.preventDefault();
          this.handleTextSend();
        } else {
          this.messageTxt = this.messageTxt + '
';
        }
      }
    },
// 发送消息
handleTextSend() {

}

  

原文地址:https://www.cnblogs.com/bgwhite/p/12160559.html