From 93c13be8cdefd3fbe3a6bbc4b4517255cf69b90a Mon Sep 17 00:00:00 2001 From: DCloud_LXH <283700113@qq.com> Date: Mon, 22 Jul 2024 13:57:19 +0800 Subject: [PATCH] =?UTF-8?q?fix:=20tabBar.list=20=E5=8F=AF=E8=83=BD?= =?UTF-8?q?=E4=B8=BA=E7=A9=BA=E5=AE=B9=E9=94=99=E5=A4=84=E7=90=86?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- packages/uni-cli-shared/src/json/pages.ts | 8 +++----- packages/uni-cli-shared/src/json/theme.ts | 2 +- 2 files changed, 4 insertions(+), 6 deletions(-) diff --git a/packages/uni-cli-shared/src/json/pages.ts b/packages/uni-cli-shared/src/json/pages.ts index 9bf0011d94..99a435649f 100644 --- a/packages/uni-cli-shared/src/json/pages.ts +++ b/packages/uni-cli-shared/src/json/pages.ts @@ -459,18 +459,16 @@ const DEFAULT_TAB_BAR: Partial = { iconWidth: '24px', spacing: '3px', height: TABBAR_HEIGHT + 'px', + list: [], } function normalizeTabBar( tabBar: UniApp.TabBarOptions, platform: UniApp.PLATFORM ) { - const { list, midButton } = tabBar - if (!list || !list.length) { - return - } + const { midButton } = tabBar tabBar = extend({}, DEFAULT_TAB_BAR, tabBar) - list.forEach((item) => { + tabBar.list.forEach((item) => { if (item.iconPath) { item.iconPath = normalizeFilepath(item.iconPath) } diff --git a/packages/uni-cli-shared/src/json/theme.ts b/packages/uni-cli-shared/src/json/theme.ts index 64a1235dde..5ba6049293 100644 --- a/packages/uni-cli-shared/src/json/theme.ts +++ b/packages/uni-cli-shared/src/json/theme.ts @@ -56,7 +56,7 @@ function normalizeUniConfigThemeJsonIconPath( ) { // 处理 tabbar 下 list -> item -> iconPath、selectedIconPath; midButton -> backgroundImage 路径 / 不开头的情况 const tabBar = pagesJson.tabBar - if (tabBar) { + if (tabBar && tabBar.list && tabBar.list.length) { tabBar.list.forEach((item) => { if (item.iconPath && item.iconPath.indexOf('@') === 0) { parseThemeJsonIconPath(themeConfig, item.iconPath.replace(/^@/, '')) -- GitLab