diff --git a/src/components/ui/VnPaginate.vue b/src/components/ui/VnPaginate.vue index b259bf8be..3328dc437 100644 --- a/src/components/ui/VnPaginate.vue +++ b/src/components/ui/VnPaginate.vue @@ -83,7 +83,12 @@ const store = arrayData.store; onMounted(() => { if (props.autoLoad) fetch(); }); - +// watch( +// () => arrayData, +// () => { +// console.error(this); +// } +// ); watch( () => props.data, () => { @@ -127,7 +132,7 @@ async function paginate() { } function endPagination() { - hasMoreData.value = arrayData.hasMoreData.value; + // hasMoreData.value = store.hasMoreData.value; isLoading.value = false; emit('onFetch', store.data); emit('onPaginate'); @@ -183,11 +188,13 @@ defineExpose({ fetch, addFilter }); + diff --git a/src/composables/useArrayData.js b/src/composables/useArrayData.js index 093806567..c3d969f55 100644 --- a/src/composables/useArrayData.js +++ b/src/composables/useArrayData.js @@ -20,6 +20,13 @@ export function useArrayData(key, userOptions) { const page = ref(1); + // watch( + // () => store.hasMoreData, + // () => { + // hasMoreData.value = store.hasMoreData; + // arrayDataStore.$state.console.error(this); + // } + // ); onMounted(() => { setOptions(); @@ -98,7 +105,7 @@ export function useArrayData(key, userOptions) { const { limit } = filter; hasMoreData.value = response.data.length >= limit; - + store.hasMoreData = hasMoreData.value; if (append) { if (!store.data) store.data = []; for (const row of response.data) store.data.push(row); @@ -169,7 +176,7 @@ export function useArrayData(key, userOptions) { } async function loadMore() { - if (!hasMoreData.value) return; + if (!hasMoreData.value && !store.hasMoreData) return; store.skip = store.limit * page.value; page.value += 1;