• vue mint-ui 框架下拉刷新上拉加载组件的使用


    安装

    npm i mint-ui -S

    然后在main.js中引入

    import MintUI from 'mint-ui'
    import 'mint-ui/lib/style.css'
    Vue.use(MintUI)
    

    下拉刷新上拉加载更多数据

    <mt-loadmore :top-method="loadTop" :bottom-method="loadBottom" :bottom-all-loaded="allLoaded" ref="loadmore">
            <ul class="track-list">
              <li class="track-item" v-for="(item,index) in list" :key="index">
                哎哎哎
              </li>
            </ul>
          </mt-loadmore>
    
    • top-method绑定的是下拉刷新触发的方法
    • bottom-method是上拉加载触发的方法
    • bottom-all-loaded绑定的是否已加载完全部数据 ,默认为false,如果全部加载完数据之后,将allLoaded设置为true,这样就不会再去触发上拉加载的方法了

    this.allLoaded = true;

    全部代码

    <mt-loadmore :top-method="loadTop" :bottom-method="loadBottom" :bottom-all-loaded="allLoaded" ref="loadmore">
            <ul class="track-list" v-if="list.length!==0">
              <li class="track-item" v-for="(item,index) in list" :key="index">
                <div class="location"><span class="iconfont icon-location"></span>{{item.address}}附近</div>
                <div class="time"><span class="iconfont icon-time"></span>{{item.dateCreated}}</div>
              </li>
            </ul>
            <div class="no-data" v-else>暂无孩子轨迹位置信息</div>
          </mt-loadmore>
    
    
    
    // 下拉刷新
        loadTop(){
          this.curPage = 1
          this.getChildLocationList()
        },
        // 加载更多数据
        loadBottom(){
          this.curPage +=1
          this.getChildLocationList()
        },
    
    
        getChildLocationList(){
          this.allLoaded = false
          let dateCreated = this.dateCreated
          this.$api.childLocationList({
            params:{
              id:this.uid,
              cid:this.curChildId,
              dateCreated:dateCreated,
              isPager:1,//0-不分页,1-分页;
              pageNum:this.curPage,//第几页
              pageSize:this.pageSize//每页显示数据条数
            }
          }).then(res=>{
            if(res.code==2000){
              if(res.row){
                let _list = res.row.list
                this.curPage = res.row.pageNum
                this.pageSize = res.row.pageSize
                let totalPages = res.row.pages//总页数
                // 下拉刷新 加载更多
                setTimeout(() => {
                  this.$refs.loadmore.onTopLoaded();
                  this.$refs.loadmore.onBottomLoaded();
                }, 1000);
                if(this.curPage==1){
                  this.list = _list;
                }else{
                  if(this.curPage==totalPages){
                    this.allLoaded = true;// 若数据已全部获取完毕
                  }
                  this.list = this.list.concat(_list);//数组追加
                }
              }else{
                this.$refs.loadmore.onTopLoaded();
                this.allLoaded = true;// 若数据已全部获取完毕
                this.list = []
              }
            }else{
              this.$refs.loadmore.onTopLoaded();
            }
          })
        },
    
  • 相关阅读:
    SQL Server 锁的 8 种类型
    MYSQL 提取时间中的信息的 4 方法
    MYSQL 时间计算的 3 种函数
    MYSQL 的 6 个返回时间日期函数
    SQL Server 错误18456
    MYSQL <=>运算符
    django比较相等或者不相等的模板语法ifequal / ifnotequal
    django模板语言的注释
    ECharts修改坐标轴,坐标轴字体,坐标轴网格样式以及控制坐标轴是否显示
    http://www.cnblogs.com/linxiyue/p/8244724.html
  • 原文地址:https://www.cnblogs.com/fozero/p/10863611.html
Copyright © 2020-2023  润新知