在store中方法存储
// 处理各模块主列表页面滚动条返回顶部
handleDocumentToTop() {
const el = document.querySelector('.portal-main');
let step = 0;
const interval = setInterval(() => {
if (el.scrollTop <= 0) {
clearInterval(interval);
return;
}
step += 10;
el.scrollTop -= step;
}, 20);
},
页面中使用
this.$nextTick(() => {
this.handleDocumentToTop();
});
也可以使用:scrollIntoView