diff --git a/src/components/VnTable/VnTable.vue b/src/components/VnTable/VnTable.vue index 444ca15bd..4e40c0ba6 100644 --- a/src/components/VnTable/VnTable.vue +++ b/src/components/VnTable/VnTable.vue @@ -124,7 +124,7 @@ const tableModes = [ ]; onBeforeMount(() => { setUserParams(route.query[$props.searchUrl]); - hasParams.value = Object.keys(params.value).length !== 0; + hasParams.value = params.value && Object.keys(params.value).length !== 0; }); onMounted(() => { @@ -158,7 +158,10 @@ function setUserParams(watchedParams) { if (!watchedParams) return; if (typeof watchedParams == 'string') watchedParams = JSON.parse(watchedParams); - const filter = JSON.parse(watchedParams?.filter); + const filter = + typeof watchedParams?.filter == 'string' + ? JSON.parse(watchedParams?.filter) + : watchedParams?.filter; const where = filter?.where; const order = filter?.order; @@ -281,6 +284,7 @@ defineExpose({ v-model="params" :search-url="searchUrl" :redirect="!!redirect" + @set-user-params="setUserParams" >