【发布时间】:2020-10-28 12:48:58
【问题描述】:
我想问如何使用Vue和vuex显示更多数据。已经存储在 vuex-store 管理中的所有数据。现在我想从状态管理中加载更多关于滚动的数据。 我找到了ajax的在线解决方案。但我需要加载表单状态管理(Vuex)。
这是我的 Vue 模板:
<template>
<div>
<div class="panel panel-default">
<div class="panel-body">
<table class="table table-bordered table-striped">
<thead>
<tr>
<tr>
<th>Name - Number of Products: <span style="color: red"> {{products}} </span></th>
<th width="100"> </th>
</tr>
</tr>
</thead>
<tbody v-if="isLoaded">
<tr v-for="company, index in companies">
<td>{{ company.name }}</td>
</tr>
</tbody>
</table>
</div>
</div>
</div>
</template>
<script>
export default {
data: function () {
return { }
},
computed: {
companies(){
return this.$store.getters['exa1Company/getProducts'];
},
products(){
return this.$store.getters['exa1Company/countProducts'];
}
},
mounted() {
this.$store.dispatch('exa1Company/indexResource');
}
}
</script>
为了简单起见,我的 vuex 存储文件是部分的
export const getters = {
countProducts(state) {
return state.list.data.length;
},
getProducts(state) {
return state.list.data;
},
getTodoById: (state) => (id) => {
return state.list.data.find(tod => tod.id === id)
}
};
export default {
namespaced: true,
state: customerState,
getters,
actions,
mutations,
};
【问题讨论】:
标签: vue.js scroll lazy-loading vuex loading