增加键盘按下事件(Enter)

上级 39fed091
...@@ -32,7 +32,19 @@ export default { ...@@ -32,7 +32,19 @@ export default {
dialogs: [] dialogs: []
} }
}, },
mounted() {
// 增加键盘按下事件
document.addEventListener('keydown', this.handleKeyDown)
},
beforeDestroy() {
document.removeEventListener('keydown', this.handleKeyDown)
},
methods: { methods: {
handleKeyDown(event) {
if (event.keyCode === 13) { // keyCode为13表示Enter键
this.handleSend()
}
},
handleSend() { handleSend() {
if (this.loading || this.question === '') return; if (this.loading || this.question === '') return;
this.loading = true; this.loading = true;
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册