vue-InfiniteScroll无限滚动

<!DOCTYPE html>
<html>

<head>
  <meta charset="UTF-8">
  <!-- import CSS -->
  <link rel="stylesheet" href="https://unpkg.com/element-ui/lib/theme-chalk/index.css">
  <style>
  </style>
</head>

<body>
  <div id="app">
    <div class="infinite-list-wrapper" style="height: 100px; 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">Loading...</p>
      <p v-if="noMore">There is no more</p>
    </div>
  </div>
</body>
<!-- import Vue before Element -->
<script src="https://unpkg.com/vue/dist/vue.js"></script>
<!-- import JavaScript -->
<script src="https://unpkg.com/element-ui/lib/index.js"></script>
<script>
  new Vue({
     
    el: '#app',
    data: function () {
     
      return {
     
        count: 10,
        loading: false
      }
    },
    computed: {
     
      noMore() {
     
        return this.count >= 20
      },
      disabled() {
     
        return this.loading || this.noMore
      }
    },
    created() {
     },
    methods: {
     
      load() {
     
        this.loading = true
        setTimeout(() => {
     
          this.count += 2
          this.loading = false
        }, 2000)
      }
    },
  })
</script>

</html>

你可能感兴趣的:(js,vue-lemenet无线滚动,vue)