從這位大哥這看到的
https://blog.csdn.net/weixin_42981560/article/details/93875904
我的需求是將"評論"的list列表的滾動條固定在底部,每當有新的評論,或者添加了評論就能看到最新的.
mounted() {
this.scrollToBottom();
},
updated: () {
this.scrollToBottom();
},
method(){
scrollToBottom() {
this.$nextTick(() => {
var container = this.$el.querySelector("#你要實現滾動條置底的元素ID");
container.scrollTop = container.scrollHeight;
})
}
}