新消息自动滚动到底部

This commit is contained in:
2023-10-22 20:06:44 +08:00
parent f79a2b2f66
commit e269d013e2
1 changed files with 5 additions and 0 deletions

View File

@ -208,6 +208,7 @@ export default class Chat {
}
return `${year}${month}${day}${hour}:${minute}`
}
const scroll = this.ul.scrollHeight === this.ul.clientHeight + this.ul.scrollTop
this.ul.appendChild(ListItem({
style: {
display: 'flex',
@ -244,6 +245,10 @@ export default class Chat {
})
]
}))
if (scroll) {
console.log('滚动到底部')
this.ul.scrollTop = this.ul.scrollHeight
}
}
async 存储消息(data) {
// 检查id是否已经存在