博客
关于我
better-sroll 下拉刷新,下拉加载vue.js参考代码
阅读量:372 次
发布时间:2019-03-05

本文共 2698 字,大约阅读时间需要 8 分钟。

<template>    <div class="test">        <div class="loading-top" v-show="topshow">            <div class="weui-loadmore">                <i class="weui-loading"></i>                <span class="weui-loadmore__tips">正在加载</span>            </div>        </div>        <div class="wrapper" ref="wrapper" :class="{'list-top': topshow}">            <div class="content">                <ul>                    <li>11</li>                    <li>22</li>                    <li>33</li>                    <li>44</li>                    <li>55</li>                    <li>66</li>                    <li>77</li>                    <li>88</li>                    <li>99</li>                </ul>            </div>        </div>    </div></template><script>import BSscroll from 'better-scroll';export default {    name: "TestContent",    data() {        return {            topshow: false        }    },    mounted() {        this.$nextTick(() => {            //$refs绑定元素            if (!this.scroll) {                this.scroll = new BSscroll(this.$refs.wrapper, {                    //开启点击事件, 默认为fasle                    click: true,                    scrollY: true,                    pullUpLoad: {                        threshold: -30, // 当上拉距离超过30px时触发 pullingUp 事件                    },                    pullDownRefresh: {                        threshold: 30, // 下拉距离超过30px触发pullingDown事件                        stop: 20 // 回弹停留在距离顶部20px的位置                    }                })                //上滑加载                this.scroll.on('pullingUp', () => {                    console.log('pullingUp');                    this.scroll.finishPullUp(); // 事情做完,需要调用此方法告诉 better-scroll 数据已加载,否则上拉事件只会执行一次                })                //下拉刷新                this.scroll.on('pullingDown', () => {                    console.log('pullingDown');                    this.topshow = true;                    setTimeout(() => {                        this.topshow = false;                    }, 2000);                    this.scroll.finishPullDown(); // 事情做完,需要调用此方法告诉 better-scroll 数据已加载,否则下拉事件只会执行一次                });            } else if (!this.$refs.wrapper) {                return            } else {                this.scroll.refresh()            }        })    }};</script><style lang="stylus" scoped>.test    clear: both    .wrapper        width: 100%        position: absolute        top: 45px        bottom: 50px        overflow: hidden        z-index: 1        li            line-height: 70px            text-align: center            background: orange            margin: 10px 0.loading-top    position: absolute    top: 20px    height: 20px    width: 100%.list-top    top: 80px !important</style>

 

转载地址:http://gcdwz.baihongyu.com/

你可能感兴趣的文章
纯客户端页面关键字搜索高亮jQuery插件
查看>>
秋月何时了,CSS3 border-radius知多少?
查看>>
linux运维中常用的命令
查看>>
M1芯片的macbook安装王者荣耀,原神,崩坏方法
查看>>
CentOS7更改成阿里云的源
查看>>
Java温故而知新-反射机制
查看>>
Netty3事件处理顺序问题
查看>>
eclipse引用sun.misc开头的类
查看>>
firefox中angular2嵌套发送请求问题
查看>>
Netty 知识整理 (2)HttpServerCodec和HttpObjectAggregator用法
查看>>
【Linux】service命令
查看>>
【mysql】事务隔离与mvcc的误区
查看>>
【mybatis3】调试/断点打印日志
查看>>
【linux】pid file解读
查看>>
【Redis】Java操作redis集群cluster
查看>>
clickhours数据库SQL查询语句问题
查看>>
Leetcode刷题bug记录
查看>>
Leetcode 102题.从中序与后序遍历序列构造二叉树
查看>>
C++
查看>>
vue-router 路由守卫和执行顺序
查看>>