From 4d968f5c729d68f8b121dac8e0777100218cc458 Mon Sep 17 00:00:00 2001 From: wangqiao Date: Mon, 1 Sep 2025 11:21:04 +0800 Subject: [PATCH] =?UTF-8?q?=E4=BC=98=E5=8C=96footer=E7=BB=84=E4=BB=B6?= =?UTF-8?q?=E6=95=B0=E6=8D=AE=E8=8E=B7=E5=8F=96=E9=80=BB=E8=BE=91?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- components/kl-footer/index.vue | 24 +++++++++++++----------- 1 file changed, 13 insertions(+), 11 deletions(-) diff --git a/components/kl-footer/index.vue b/components/kl-footer/index.vue index ef4d0ab..14a1c2e 100644 --- a/components/kl-footer/index.vue +++ b/components/kl-footer/index.vue @@ -84,19 +84,21 @@ status: 0, }) - const bannerList = ref>([]) - const getBanner = async () => { + // 方案1: 直接在useAsyncData中通过泛型设置类型(当前已使用的方式) + const { data: arr } = await useAsyncData('projectTypeListChildren-PopularDrawings-popularDrawings', async (): Promise => { const res = await getSettingPage(pageReq) - if (res.code === 0) { - const arr = res.data || [] - const bannerListOne = arr.filter((item) => item.rowType === 1)?.sort((a, b) => a.sort - b.sort) - const bannerListTwo = arr.filter((item) => item.rowType === 2)?.sort((a, b) => a.sort - b.sort) - const bannerListThree = arr.filter((item) => item.rowType === 3)?.sort((a, b) => a.sort - b.sort) - const bannerListFour = arr.filter((item) => item.rowType === 4)?.sort((a, b) => a.sort - b.sort) - bannerList.value = [bannerListOne, bannerListTwo, bannerListThree, bannerListFour] - } + return res?.data || [] + }) + + const bannerList = ref>([]) + if (arr && arr.value?.length) { + const bannerListOne = arr.value?.filter((item) => item.rowType === 1)?.sort((a, b) => a.sort - b.sort) + const bannerListTwo = arr.value?.filter((item) => item.rowType === 2)?.sort((a, b) => a.sort - b.sort) + const bannerListThree = arr.value?.filter((item) => item.rowType === 3)?.sort((a, b) => a.sort - b.sort) + const bannerListFour = arr.value?.filter((item) => item.rowType === 4)?.sort((a, b) => a.sort - b.sort) + bannerList.value = [bannerListOne, bannerListTwo, bannerListThree, bannerListFour] } - getBanner() + // } const handle = (col: PageResultIndexSettingRespVO[]) => { if (col?.length > 0) {