diff --git a/src/components/common/VnCard.vue b/src/components/common/VnCard.vue index 21e4cfb3e..504dd809f 100644 --- a/src/components/common/VnCard.vue +++ b/src/components/common/VnCard.vue @@ -23,6 +23,7 @@ const props = defineProps({ const stateStore = useStateStore(); const route = useRoute(); const router = useRouter(); +const regex = /(\/\d+)/; const searchRightDataKey = computed(() => { if (!props.searchDataKey) return route.name; return props.searchDataKey; @@ -35,6 +36,9 @@ const arrayData = useArrayData(props.dataKey, { onBeforeMount(async () => { try { if (props.idInWhere) arrayData.store.filter.where = { id: route.params.id }; + else if (!regex.test(props.url)) + arrayData.store.url = `${props.url}/${route.params.id}`; + await arrayData.fetch({ append: false, updateRouter: false }); } catch { const { matched: matches } = router.currentRoute.value; @@ -46,7 +50,6 @@ onBeforeMount(async () => { if (!props.idInWhere) { onBeforeRouteUpdate(async (to, from) => { if (to.params.id !== from.params.id) { - const regex = /(\/\d+)/; arrayData.store.url = !regex.test(props.url) ? `${props.url}/${to.params.id}` : props.url.replace(regex, `/${to.params.id}`);