VUE、js方法页面点击滚到最底部
2021-07-15 本文已影响0人
生于乱世
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()
})