亚洲乱码中文字幕综合,中国熟女仑乱hd,亚洲精品乱拍国产一区二区三区,一本大道卡一卡二卡三乱码全集资源,又粗又黄又硬又爽的免费视频

vue進(jìn)入頁(yè)面時(shí)滾動(dòng)條始終在底部代碼實(shí)例

 更新時(shí)間:2019年03月26日 15:28:44   作者:sayid760  
這篇文章主要介紹了vue進(jìn)入頁(yè)面時(shí)滾動(dòng)條始終在底部,文中通過示例代碼介紹的非常詳細(xì),對(duì)大家的學(xué)習(xí)或者工作具有一定的參考學(xué)習(xí)價(jià)值,需要的朋友們下面隨著小編來一起學(xué)習(xí)學(xué)習(xí)吧

本文實(shí)例為大家分享了vue進(jìn)入頁(yè)面時(shí)滾動(dòng)條始終在底部的具體代碼,供大家參考,具體內(nèi)容如下

mounted () {
 this.scrollToBottom();
},
//每次頁(yè)面渲染完之后滾動(dòng)條在最底部
updated:function(){
 this.scrollToBottom();
},
methods:{
 scrollToBottom: function () {
  this.$nextTick(() => {
	 var container = this.$el.querySelector(".chatBox-content-demo");
  container.scrollTop = container.scrollHeight;
  })
}
}

滾動(dòng)條樣式:

::-webkit-scrollbar {
 width: 5px;
 height: 5px;
}
 
::-webkit-scrollbar-track-piece {
 background-color: rgba(0, 0, 0, 0.2);
 -webkit-border-radius: 6px;
}
 
::-webkit-scrollbar-thumb:vertical {
 height: 5px;
 background-color: rgba(125, 125, 125, 0.7);
 -webkit-border-radius: 6px;
}
 
::-webkit-scrollbar-thumb:horizontal {
 width: 5px;
 background-color: rgba(125, 125, 125, 0.7);
 -webkit-border-radius: 6px;
}

 如果使用了better-scroll

在created()或者mounted () 里都可以
 
mounted () {
 this.$nextTick(() => {
 this._initScroll();
 let allLi=this.$refs.chatcontheight.querySelectorAll("li");
 this.chartScroll.scrollToElement(allLi[allLi.length-1],0);
 });
},
//每次頁(yè)面渲染完之后滾動(dòng)條在最底部
updated:function(){
  this.$nextTick(() => {
this._initScroll();
let allLi=this.$refs.chatcontheight.querySelectorAll("li");
this.chartScroll.scrollToElement(allLi[allLi.length-1],0);
  });
},
methods:{
 _initScroll(){
this.chartScroll=new BScroll(this.$refs.chatcontheight,{
   click:true
  })
}}
 
結(jié)構(gòu)
<div ref="$refs.chatcontheight" style="overflow: hidden;">
  <ul>
 <li></li>
  </ul>
</div>

以上所述是小編給大家介紹的vue進(jìn)入頁(yè)面時(shí)滾動(dòng)條始終在底部詳解整合,希望對(duì)大家有所幫助,如果大家有任何疑問請(qǐng)給我留言,小編會(huì)及時(shí)回復(fù)大家的。在此也非常感謝大家對(duì)腳本之家網(wǎng)站的支持!

相關(guān)文章

最新評(píng)論