问题:项目中在text area中shift+enter换行,keyup.enter发送信息,但是shift+enter换行触发了键盘keyup.enter事件
<el-input
ref="textInput"
@keydown.shift.enter.prevent="handleShiftEnter"
@keyup.enter.exact.prevent="handleSearch"
v-model="queryText"
:autosize="{ minRows: 2, maxRows: 4 }"
type="textarea"
placeholder="输入您想搜索的问题,shift+enter换行"
class="search-input"
/>
const handleShiftEnter = (event) => {
// 阻止 keyup.enter 事件
event.preventDefault()
const textarea = textInput.value.textarea; //获取输入框元素
const start = textarea.selectionStart;
const end = textarea.selectionEnd;
const value = textarea.value;
const newValue = value.substring(0, start) + "\n" + value.substring(end);
textarea.value = newValue;
textarea.selectionStart = textarea.selectionEnd = start + 1;
}
const handleSearch = () {
console.log('发送')
}