(亲测可用)vue新消息自动滚到底部
mounted () { this.scrollToBottom(); }, //每次页面渲染完之后滚动条在最底部 updated:function(){ this.scrollToBottom(); }, methods: { // scrollToBottom() { this.$nextTick(() => { var container = this.$el.querySelector(" 需要滚动条处于底部的容器,css类名 "); container.scrollTop = container.scrollHeight; })} } ``` 关于获取this.$el.querySelector的知识,可以参考这里: [this.$el.querySelector](https://developer.mozilla.org/zh-CN/docs/Web/API/Element/querySelector)
相关推荐
vavid 2018-04-15
ajhongshaorou 2019-06-29
武林半侠 2019-06-29
gigipop 2019-06-28
dangzhangjing 2019-06-27
语帆 2015-04-15
zhouguizhi 2013-02-28
AlisaClass 2012-11-20
淡风wisdon大大 2012-08-16
SuiKaSan的自学室 2012-08-11
AnyBisks 2011-11-27
liusure0 2011-09-27
startXUEBA 2011-07-19
xiaohuli 2011-05-11
Ydgent 2012-07-28
Juey 2017-07-21