发送按钮
This commit is contained in:
parent
cabab4890b
commit
df3500f6c5
23
src/chat.js
23
src/chat.js
@ -21,14 +21,31 @@ export default class Chat {
|
||||
boxSizing: 'border-box',
|
||||
boxShadow: '0 0 1rem #eee',
|
||||
},
|
||||
onkeydow1n: event => {
|
||||
onkeydown: event => {
|
||||
const text = event.target.value.trim()
|
||||
if (text && event.key === 'Enter') {
|
||||
if (text && event.ctrlKey && event.key === 'Enter') {
|
||||
this.发送消息(text)
|
||||
event.target.value = ''
|
||||
}
|
||||
}
|
||||
}, 'textarea')
|
||||
}, 'textarea'),
|
||||
Button({
|
||||
textContent: '发送(ctrl+Enter)',
|
||||
onclick: event => {
|
||||
const text = event.target.previousSibling.value.trim()
|
||||
if (text) {
|
||||
this.发送消息(text)
|
||||
event.target.previousSibling.value = ''
|
||||
}
|
||||
},
|
||||
style: {
|
||||
margin: '1rem 2rem',
|
||||
padding: '.5rem 1rem',
|
||||
boxSizing: 'border-box',
|
||||
boxShadow: '0 0 1rem #eee',
|
||||
borderRadius: '1rem',
|
||||
}
|
||||
}),
|
||||
]
|
||||
}))
|
||||
// 写入 css 样式到 head
|
||||
|
Loading…
Reference in New Issue
Block a user