Vue.js 用类星体的infinte涡旋滤波vue

Vue.js 用类星体的infinte涡旋滤波vue,vue.js,quasar-framework,Vue.js,Quasar Framework,我看到类星体infinte scroll()是基于将“新”的物体推到模型中 但是我已经使用Getter将我自己变成了一个过滤器(10+个过滤器),Getter返回数据(参见我的代码示例) 我的问题是如何才能做到最好? 是否可以实现无限滚动而无需按下它? 或者页面很难呈现150-200-250,因为它呈现了所有内容 我应该这样做吗?它会推动接下来的5个阵列? 如果是这样的话,我怎么能确定它的第一时间是20秒。下一个是21-40,下一个是41-60…等等 我的代码示例 无限涡旋类星体 HTML

我看到类星体infinte scroll()是基于将“新”的物体推到模型中

但是我已经使用Getter将我自己变成了一个过滤器(10+个过滤器),Getter返回数据(参见我的代码示例)

我的问题是如何才能做到最好?

  • 是否可以实现无限滚动而无需按下它? 或者页面很难呈现150-200-250,因为它呈现了所有内容
  • 我应该这样做吗?它会推动接下来的5个阵列? 如果是这样的话,我怎么能确定它的第一时间是20秒。下一个是21-40,下一个是41-60…等等
我的代码示例

无限涡旋类星体
HTML

const store = new Vuex.Store({
  state: {
    items: [
      {"id": "123", "category": "AAA"},
      {"id": "124", "category": "BBB"},
      {"id": "125", "category": "AAA"},
      {"id": "126", "category": "CCC"},
      {"id": "127", "category": "DDD"},
      {"id": "128", "category": "AAA"}
    ]
  },
  getters: {
    filteredItems: state => currentCategory => {
      if( currentCategory == null ) {
        return state.items;
      }
      return state.items.filter( itm => itm.category == currentCategory );
    }
  }
});

new Vue({
  el: "#app",
  store,
  template: `
  <section class="section">
    <h1 class="title">Vuex Getter Filter #2</h1>
    <div class="content">
      <p>This demonstrates how a list of items maintained in Vuex state can be filtered using a getter.  An HTML <code>&lt;select&gt;</code> manipulates a data field "currentCategory" which is bound to the select with a v-model.  The v-model value is used as the parameter to a Vuex getter.</p>
    <p>
For an alternative CodePen in which "currentCategory" is kept as state in Vuex follow <a href="https://codepen.io/walkerca/pen/rNNKpja" target="_blank" >this link</a>.
</p>
    </div>
    <div class="field">
      <label class="label">Filter On</label>
      <div class="control">
        <div class="select">
          <select v-model="currentCategory">
            <option :value="null">Select Category</option>
            <option value="AAA">AAA</option>
            <option value="BBB">BBB</option>
            <option value="CCC">CCC</option>
          </select>
        </div>
      </div>
    </div>
    <table class="table is-fullwidth">
      <thead><tr><th>Id</th><th>Category</th></tr></thead>
      <tbody>
        <tr v-for="itm in $store.getters.filteredItems(currentCategory)" :key="itm.id">
          <td>{{ itm.id }}</td>
          <td>{{ itm.category }}</td>
        </tr>
      </tbody>
    </table>
  </div>
</section>
`,
  data: {
    currentCategory: null
  }
});
<div id="q-app">
  <div class="q-pa-md">
    <q-infinite-scroll @load="onLoad" :offset="250">
      <div v-for="(item, index) in items" :key="index" class="caption">
        <p>Lorem ipsum dolor sit amet consectetur adipisicing elit. Rerum repellendus sit voluptate voluptas eveniet porro. Rerum blanditiis perferendis totam, ea at omnis vel numquam exercitationem aut, natus minima, porro labore.</p>
      </div>
      <template v-slot:loading>
        <div class="row justify-center q-my-md">
          <q-spinner-dots color="primary" size="40px"></q-spinner-dots>
        </div>
      </template>
    </q-infinite-scroll>
  </div>
</div>
new Vue({
  el: '#q-app',
  data () {
    return {
      items: [ {}, {}, {}, {}, {}, {}, {} ]
    }
  },

  methods: {
    onLoad (index, done) {
      setTimeout(() => {
        if (this.items) {
          this.items.push({}, {}, {}, {}, {}, {}, {})
          done()
        }
      }, 2000)
    }
  }
})