chjtx / JRoll

Smooth scrolling for the mobile web
http://www.chjtx.com/JRoll/
MIT License
460 stars 92 forks source link

请问jroll-vue-infinite中数据全部加载完成时该如何调用 #40

Closed wuhan169 closed 7 years ago

wuhan169 commented 7 years ago

上拉加载中,demo是否考虑加上全部数据加载完成时代码的调用

chjtx commented 7 years ago

@wuhan169 有个total选项,可自行根据total和page这两个值进行判断

// vue实例
    var vm
    var infOptions = {
      total: 10,
      bottomed: function () {
        var me = this
        ajax({
          url: 'getData.do?page=' + (me.page + 1),
          success: function (data) {
            vm.$data.items = vm.$data.items.concat(data)
            me.success()
            // 判断是否在最后一页
           if (me.page === me.total) {
             // 干你要干的事情
           }
          },
          error: function () {
            me.error()
          }
        })
      },
      updated: function () {
        console.log('current page is ' + this.page)
      }
    }

    vm = new Vue({
      el: '#app',
      components: {
        'jroll-infinite': JRoll.VueInfinite(infOptions, { scrollBarY: true })
      },
      data: {
        items: []
      }
    })
wuhan169 commented 7 years ago

谢谢!也可以直接修改tip表示加载完成