Vue 將某個元素的滾動條固定在底部

從這位大哥這看到的

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;
       })
    }
   }   

 

發表評論
所有評論
還沒有人評論,想成為第一個評論的人麼? 請在上方評論欄輸入並且點擊發布.
相關文章