From e0507f3bd123bc0953e37d0330dd4c4c906019c4 Mon Sep 17 00:00:00 2001 From: wangqiao Date: Tue, 2 Sep 2025 18:28:24 +0800 Subject: [PATCH] =?UTF-8?q?=E4=BC=98=E5=8C=96=E5=A3=81=E7=BA=B8=E5=88=86?= =?UTF-8?q?=E7=B1=BB=E7=BB=84=E4=BB=B6=E6=95=B0=E6=8D=AE=E8=8E=B7=E5=8F=96?= =?UTF-8?q?=E9=80=BB=E8=BE=91?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- components/kl-wallpaper-category/index.vue | 16 +++++++--------- 1 file changed, 7 insertions(+), 9 deletions(-) diff --git a/components/kl-wallpaper-category/index.vue b/components/kl-wallpaper-category/index.vue index 69a1f1e..1001af5 100644 --- a/components/kl-wallpaper-category/index.vue +++ b/components/kl-wallpaper-category/index.vue @@ -84,7 +84,7 @@ }) /** 版本 */ - const { data: editionsList } = useAsyncData(`editionsList-${props.type}-${Date.now()}`, async () => { + const { data: editionsList } = useAsyncData(`editionsList-${props.type}}`, async () => { const res = await parent({ type: 2, parentId: 0 }) const all = [{ id: '-1', name: '全部' }] return [...all, ...res.data] @@ -92,7 +92,7 @@ // 获取面包屑 const { data: breadList } = await useAsyncData( - `breadList-${props.type}-${props.id}-${query.value.projectType}-${Date.now()}`, + `breadList-${props.type}-${props.id}-${query.value.projectType}}`, async () => { const res = await getDictTree({ type: 1, id: query.value.projectType }) const all = [ @@ -104,13 +104,8 @@ ] const arr = [...res.data, ...all] return arr.reverse() - }, - { - immediate: true, } ) - - console.log('breadList', breadList); // const projectTypeList = ref([]) /** 获取分类下拉框 */ @@ -140,7 +135,7 @@ // } // getEditionsList() - console.log('breadList.value.length----', breadList.value?.length); + console.log('breadList.value.length----', breadList.value); // 服务端渲染兼容方案:顺序执行异步操作 // 1. 先获取面包屑数据(已在上面通过useAsyncData获取) @@ -160,6 +155,9 @@ parentId = breadList?.value[length - 1].id } } + + console.log('parentId', parentId); + try { // 获取分类数据 @@ -174,7 +172,7 @@ // 使用useAsyncData获取分类列表,确保服务端渲染兼容性 const { data: projectTypeList } = await useAsyncData( - `projectType-draw-${props.type}-${query.value.projectType}-${Date.now()}`, + `projectType-draw-${props.type}-${query.value.projectType}}`, getProjectTypeList, { server: true } // 确保在服务端执行 )