BaseRefreshScroll.vue 1019 Bytes
Newer Older
leiqingsong's avatar
leiqingsong committed
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24
<template>
  <div id="minirefresh" class="minirefresh-wrap">
    <div class="minirefresh-scroll">
      <slot name="content" />
    </div>
  </div>
</template>

<script>
export default {
  name: "BaseRefreshScroll",
  data() {
    return {
      pageNo: 1
    };
  },
  mounted() {
    this.refresh();
  },
  methods: {
    refresh() {
      const that = this;
      this.miniRefresh = new window.MiniRefresh({
        container: "#minirefresh",
leiqingsong's avatar
leiqingsong committed
25
        isScrollBar: false,
leiqingsong's avatar
leiqingsong committed
26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50
        down: {
          offset: 50,
          callback: function() {
            that.pageNo = 1;
            that.$emit("downLoad", that.pageNo);
            that.miniRefresh.endDownLoading();
          }
        },
        up: {
          offset: 50,
          isAuto: false,
          toTop: {
            isEnable: false
          },
          callback() {
            that.pageNo++;
            that.$emit("upRefresh", that.pageNo);
            that.miniRefresh.endUpLoading(false);
          }
        }
      });
    }
  }
};
</script>