其他分享
首页 > 其他分享> > vue-infinite-scroll 滚动加载下一页

vue-infinite-scroll 滚动加载下一页

作者:互联网

<template>
  <div class="infinite-list-wrapper" style="overflow:auto">
    <ul
      class="list"
      v-infinite-scroll="load"
      infinite-scroll-disabled="disabled">
      <li v-for="i in count" class="list-item">{{ i }}</li>
    </ul>
    <p v-if="loading">加载中...</p>
    <p v-if="noMore">没有更多了</p>
  </div>
</template>

<script>
  export default {
    data () {
      return {
        count: 10,
        loading: false
      }
    },
    computed: {
      noMore () {
        return this.count >= 20
      },
      disabled () {
        return this.loading || this.noMore
      }
    },
    methods: {
      load () {
        this.loading = true
        setTimeout(() => {
          this.count += 2
          this.loading = false
        }, 2000)
      }
    }
  }
</script>

  

原文链接https://www.jianshu.com/p/c4abab8c1ba6

标签:count,loading,return,noMore,vue,infinite,false,scroll,加载
来源: https://www.cnblogs.com/duhui/p/13065619.html