1.无滚动条时
// 页面滚到最底部
toBottom(){
var height = document.body.clientHeight;
window.scroll({ top: height , left: 0, behavior: 'smooth' });
}
2.有滚动条时可用
// 滚动到最底部
toBottom(){
this.$nextTick(()=>{
var scrollDom = document.getElementById('chatBox');
scrollDom.scrollTop = scrollDom.scrollHeight
})
},
方法调用
//调用
this.$nextTick(()=>{
this.toBottom()
})
网友评论