vue better-scroll 下拉上拉,加載刷新


_initScroll(){

             this .$nextTick(() => {
                 if  (! this .scroll) {
                     this .scroll =  new  BScroll( this .$refs.bscroll, {
                         click:  true ,
                         scrollY:  true ,
                         probeType: 3
                     });
                 } else {
                     this .scroll.refresh();
                 }
                 this .scroll.on( 'scroll' , (pos) => {
                     console.log(pos.y, this .dropDown)
                     //如果下拉超過50px 就顯示下拉刷新的文字
                     if (pos.y>50){
                            // 顯示刷新的element  this.xxx = true;
                     } else {
                      // 隱藏刷新的element  this.xxx = false;
                     }
                 })
                 //touchEnd(手指離開以后觸發) 通過這個方法來監聽下拉刷新
                 this .scroll.on( 'touchEnd' , (pos) => {
                     // 下拉動作
                     if (pos.y > 50){
                         console.log( "下拉刷新成功" )
                        // 隱藏刷新的element   this.xxx = false;
                     }
                     //上拉加載 總高度>下拉的高度+10 觸發加載更多
                     if ( this .scroll.maxScrollY>pos.y+10){
                         console.log( "加載更多" )
                         //使用refresh 方法 來更新scroll  解決無法滾動的問題
                         this .scroll.refresh()
                     }
                     console.log( this .scroll.maxScrollY+ "總距離----下拉的距離" +pos.y)
                 })
                 console.log( this .scroll.maxScrollY)
             });
         }


免責聲明!

本站轉載的文章為個人學習借鑒使用,本站對版權不負任何法律責任。如果侵犯了您的隱私權益,請聯系本站郵箱yoyou2525@163.com刪除。



 
粵ICP備18138465號   © 2018-2025 CODEPRJ.COM