fix(tabbar): 修复H5环境下无tabbar时的白屏问题

当tabbar缓存未启用时,将tabBar配置设为undefined而非空对象。在H5环境下,无tabbar时设置为空对象以防止浏览器报错导致白屏
This commit is contained in:
feige996
2025-09-04 15:14:21 +08:00
parent da532e03a2
commit c31090e389
2 changed files with 4 additions and 2 deletions

View File

@@ -1,3 +1,4 @@
import { isH5 } from '@uni-helper/uni-env'
import { defineUniPages } from '@uni-helper/vite-plugin-uni-pages'
import { tabBar } from './src/tabbar/config'
@@ -19,5 +20,6 @@ export default defineUniPages({
},
},
// tabbar 的配置统一在 “./src/tabbar/config.ts” 文件中
tabBar: tabBar as any,
// 无tabbar模式下h5 设置为 {} 为了防止浏览器报错导致白屏
tabBar: tabBar || (isH5 ? {} : undefined) as any,
})

View File

@@ -153,4 +153,4 @@ const _tabbar: TabBar = {
}
// 0和1 需要显示底部的tabbar的各种配置以利用缓存
export const tabBar = tabbarCacheEnable ? _tabbar : {}
export const tabBar = tabbarCacheEnable ? _tabbar : undefined