自设计聊天记录
整个聊天记录用ul标签包裹
每一条聊天记录就用一个li代表
因为用VUE写的,所以搞了个函数挂载。
chatListDown(pos, initCount){
// 滚动聊天列表到底部
const _this = this;
var scrollTimer = null
let dom = document.getElementById('chat-list')
if (!dom) {
return
}
let maxCount = 5
initCount = initCount || 1
if (typeof pos !== 'number') {
pos = Math.max(dom.scrollHeight - dom.clientHeight, 888888)
}
dom.scrollTop = pos
if ((dom.scrollTop < pos) && (initCount < maxCount)) {
clearTimeout(scrollTimer)
scrollTimer = setTimeout(() => {
initCount++
_this.scrollChatListDown(pos, initCount)
}, 200)
}
}
挂载完打开页面就是聊天界面的效果了。