All Projects → larryzhuo → vue-pull-to-refresh-and-load-more

larryzhuo / vue-pull-to-refresh-and-load-more

Licence: other
a scroll component with function of pull up refresh and pull down load more for vue

Programming Languages

javascript
184084 projects - #8 most used programming language
Vue
7211 projects

Projects that are alternatives of or similar to vue-pull-to-refresh-and-load-more

vue2-dialog
A mobile Vue plugin for VueDialog
Stars: ✭ 21 (+61.54%)
Mutual labels:  scroller
Scroller
React版iScroll并且集成下拉刷新,上拉加载更多,Sticky等功能
Stars: ✭ 52 (+300%)
Mutual labels:  scroller
c64engine
a game engine for the c64
Stars: ✭ 19 (+46.15%)
Mutual labels:  scroller
scrollRulerView
请使用 CYRuler (Please use CYRuler)
Stars: ✭ 31 (+138.46%)
Mutual labels:  scroller
Clusterize.js
Tiny vanilla JS plugin to display large data sets easily
Stars: ✭ 6,995 (+53707.69%)
Mutual labels:  scroller
Vue Virtual Scroller
⚡️ Blazing fast scrolling for any amount of data
Stars: ✭ 6,326 (+48561.54%)
Mutual labels:  scroller
v-scroller
A vue plugin for nesting scroller ,you can use it to expand more components such as banner,date-piacker and so on.
Stars: ✭ 35 (+169.23%)
Mutual labels:  scroller
CXLinkageSheetDemo
一个同时支持横向和纵向滚动的表格框架 CXLinkageSheetView,适用于一些数据展示页面
Stars: ✭ 78 (+500%)
Mutual labels:  scroller
EasyScrollDots
Single page scroll JavaScript plugin that allows for vertical navigation of page sections
Stars: ✭ 38 (+192.31%)
Mutual labels:  scroller
dynamic-marquee
A small library for creating marquees.
Stars: ✭ 64 (+392.31%)
Mutual labels:  scroller

vue-pull-to-refresh-and-load-more

a scroll component with function of pull down refresh and pull up load more for vue

I create a scroller component for vue base iscroll-lite. it support more than one scroller in one page

<template>
   <div>
      <scroller :hswipe-stop-scroll="true" :init-load-more="true" :wrapper-id="'wrapper0'" :scroll-id="'scroll0'" :need-refresh="true" :refresh-call="refresh" :load-more-call="loadMore" :has-more-data="alls[0].hasMore" :more-tip="alls[0].list.length>0">
     </scroller>
   </div>
   <div>
      <scroller :hswipe-stop-scroll="true" :wrapper-id="'wrapper1'" :scroll-id="'scroll1'" :need-refresh="true" :refresh-call="refresh" :load-more-call="loadMore" :has-more-data="alls[1].hasMore" :more-tip="alls[1].list.length>0">      
      </scroller>
   </div>
</template>
<script>
import Scroller from './iscroller/ZZScroll.vue'

const PageSize = 20;

export default{
    components: { Scroller},

    data () {
      return {
        nowType: 0,
        alls: [
          { list: [], pageNo: 1, hasMore: true },
          { list: [], pageNo: 1, hasMore: true }
        ]
        
    },

    methods: {
      initList (type, isRefresh, succCall, errCall) {
        succCall = succCall || function(){};
        errCall = errCall || function(){};
        let opt = {}, self = this, temp = this.alls[type];
        if(isRefresh) {
          temp.list.length = 0;   //不使用 =[]; 会出现短暂的空白
          temp.pageNo = 1;
          temp.hasMore = true;
        }
        opt.pageNo = temp.pageNo;
        opt.pageSize = PageSize;
        opt.status = type;
        Http.post('SAAS_H5_GetItemOrderList', opt).then((data) => {
          data = data.body;
          temp.list = temp.list.concat(data.orderList);
          self.storePhone = data.storePhone;        //保存店铺电话
          if( temp.pageNo >= Math.ceil(data.totalCount / PageSize) ){   //判断数据是否加载完全
            temp.hasMore = false;
            succCall(data);
            return;
          }
          temp.pageNo++;
          succCall(data);
        }, () => {
          errCall();
        });
      },

      refresh (scrollId) {
        let self = this;
        let type=scrollId.slice(-1);
        this.initList(type, true, function(){
          self.$broadcast('refresh-finish', {errorCode: 0, scrollId: scrollId});
        }, function(){
          self.$broadcast('refresh-finish', {errorCode: -1, scrollId: scrollId});
        })
      },
      loadMore (scrollId) {
        let self = this;
        let type=scrollId.slice(-1);
        this.initList(type, false, function(){
          self.$broadcast('load-finish', {errorCode: 0, scrollId: scrollId});
        }, function(){
          self.$broadcast('load-finish', {errorCode: -1, scrollId: scrollId});
        })
      }
    }
}
</script>

as you can see, this scroller has some props:

  • hswipe-stop-scroll: work for when you swipe scroll, stop vertical scroll.
  • init-load-more: work for if you need load data when init this component.
  • wrapper-id and scroll-id: work for specify many scroller in one page.
  • need-refresh: work for if you need the refresh and load more function.
  • refresh-call: work for pull down refresh call.
  • load-more-call: work for pull up load more call.
  • has-more-data: work for load more status, if false, it will show 'no more data'.
  • more-tip: work for control 'no more data' tip shows.

above, I give a example to use in a ajax request base vue. when you $broadcast 'refresh-finish' or 'load-finish'. remeber the transfer scrollId. and errorCode:0 is success. errorCode:-1 is false.

Note that the project description data, including the texts, logos, images, and/or trademarks, for each open source project belongs to its rightful owner. If you wish to add or remove any projects, please contact us at [email protected].