diff --git a/src/chat.js b/src/chat.js index 6a24cde..273576c 100644 --- a/src/chat.js +++ b/src/chat.js @@ -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是否已经存在