This commit is contained in:
Javier Segarra 2024-01-15 14:44:38 +01:00
parent 6304776fac
commit 972c340fad
1 changed files with 17 additions and 2 deletions

View File

@ -1,10 +1,12 @@
<script setup> <script setup>
import { onMounted, ref, watch } from 'vue'; import { onMounted, ref, watch, onUnmounted } from 'vue';
import { useI18n } from 'vue-i18n'; import { useI18n } from 'vue-i18n';
import { useArrayData } from 'composables/useArrayData'; import { useArrayData } from 'composables/useArrayData';
import { useRoute } from 'vue-router';
const { t } = useI18n(); const { t } = useI18n();
const route = useRoute();
const props = defineProps({ const props = defineProps({
dataKey: { dataKey: {
type: String, type: String,
@ -79,14 +81,27 @@ const store = arrayData.store;
onMounted(() => { onMounted(() => {
if (props.autoLoad) fetch(); if (props.autoLoad) fetch();
}); });
onUnmounted(async ()=>{
arrayData.destroy()
});
watch( watch(
() => props.data, () => props.data,
() => { () => {
// store.skip = 0;
store.data = props.data; store.data = props.data;
} }
); );
// watch(
// () => route.path,
// async (newId, oldId) => {
// if (newId!==oldId) {
// // arrayData.hasMoreData.value = [];
// arrayData.store.clear()
// }
// }
// );
async function fetch() { async function fetch() {
await arrayData.fetch({ append: false }); await arrayData.fetch({ append: false });
if (!arrayData.hasMoreData.value) { if (!arrayData.hasMoreData.value) {