这个问题很头疼,尝试了很多方法,当我用scrollTop判断到达顶部后拉取数据,但是数据拉下来后滚动条的位置就是最上面了,该如何记录原来的位置并返回呢
也就是像微信qq那样,在聊天页面里,往上拉会加载之前的聊天记录
let _this = this;
let toptop = this.messageBox.scrollTop;
if(toptop == 0){
//请求新数据
dispatch({
type: '接口',
payload: {
Id: id,
type:type,
page: 1,
size:60
},
}).then(i=>{
setTimeout(function () {
// _this.messageBox.scrollTop = 原来的位置
}, 2000);
});
}
聊天界面逻辑、下拉才是获取更多聊天记录吧