diff --git a/packages/uni-cli-shared/src/json/pages.ts b/packages/uni-cli-shared/src/json/pages.ts index 9bf0011d941ef08b7a880ba1d7b9d645759e2984..99a435649f60f24e325c1413a19462667cbff45b 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 64a1235ddef3c91df32f601ec4100997f2f033ff..5ba604929379a5f43bb1db5d11dbf4c73a212621 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(/^@/, ''))