zoukankan      html  css  js  c++  java
  • 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)
                });
            }
  • 相关阅读:
    [收藏转贴]struct探索·extern "C"含义探索 ·C++与C的混合编程·C 语言高效编程的几招
    [收藏转贴]构建RESTful风格的WCF服务
    [转贴] C/C++中动态链接库的创建和调用
    [转贴]WebService的简单实现 C++
    谷歌已经对Android的开源严防死守
    如何成为一名黑客?
    当程序员思路被打断
    编辑语言是这样的
    开发者需要掌握多少门语言?
    程序员的六大优势
  • 原文地址:https://www.cnblogs.com/xzc666/p/9455861.html
Copyright © 2011-2022 走看看