在 NativeScript-Vue 和 ListView 中管理数组大小

问题描述

我有一个带有无限滚动的 ListView,我从使用 axios 的分页 API 调用填充。

如何管理数组的大小以获得良好的应用程序性能?加载新对象时是否必须从数组中剪切第一个对象?稍后,该数组将在 Vuex 中。

例如:API 调用返回 10 个新对象,数组中有 100 个活动对象,后端数据库中有 1000 个,ListView 显示 20 个,我从数组中删除了前 10 个对象?

<ListView for="post in posts" @loadMoreItems="loadMorePosts">
    <v-template>
        <Label :text="post.title" />
        <Label :text="post.body" />         
    </v-template>
</ListView>
data() {
    return {
        posts: [],links: {},};
},loadMorePosts() {
    var that = this;
    axios.defaults.headers.common = {'Authorization': 'Bearer '+this.token}
    axios.get(this.links.next)
    .then(function (response) {
        that.posts = that.posts.concat(response.data.data);
        that.links = response.data.links;
     });
},

解决方法

暂无找到可以解决该程序问题的有效方法,小编努力寻找整理中!

如果你已经找到好的解决方法,欢迎将解决方案带上本链接一起发送给小编。

小编邮箱:dio#foxmail.com (将#修改为@)