容器
<div class="scroll">
<div ref="toBottom" @click="toBottom()"></div>
</div>
方法:关键代码在于this.$nextTick 直接使用由于vue渲染问题获取不到完整scrollHeight
方法一:使用scrollTo
toBottom(){ this.$nextTick(() => { this.$refs.toBottom.scrollTo(0,this.$refs.msgbox.scrollHeight); })
方法二: 使用scrollTop
this.$nextTick(() => {
this.$refs.msgbox.scrollTop = this.$refs.msgbox.scrollHeight
})