ソースを参照

fix(tabbar): 修复首页路径为'/'时tabbar不显示的问题

处理本地'/pages/index/index'和线上'/'路径不一致导致的tabbar显示问题
feige996 7 ヶ月 前
コミット
6b5e2f9d0b
2 ファイル変更13 行追加1 行削除
  1. 8 1
      src/App.ku.vue
  2. 5 0
      src/tabbar/store.ts

+ 8 - 1
src/App.ku.vue

@@ -11,7 +11,14 @@ const isCurrentPageTabbar = ref(true)
 onShow(() => {
   console.log('App.ku.vue onShow', currRoute())
   const { path } = currRoute()
-  isCurrentPageTabbar.value = isPageTabbar(path)
+  // “蜡笔小开心”提到本地是 '/pages/index/index',线上是 '/' 导致线上 tabbar 不见了
+  // 所以这里需要判断一下,如果是 '/' 就当做首页,也要显示 tabbar
+  if (path === '/') {
+    isCurrentPageTabbar.value = true
+  }
+  else {
+    isCurrentPageTabbar.value = isPageTabbar(path)
+  }
 })
 
 const helloKuRoot = ref('Hello AppKuVue')

+ 5 - 0
src/tabbar/store.ts

@@ -45,6 +45,11 @@ const tabbarStore = reactive({
     }
   },
   setAutoCurIdx(path: string) {
+    // '/' 当做首页
+    if (path === '/') {
+      this.setCurIdx(0)
+      return
+    }
     const index = tabbarList.findIndex(item => item.pagePath === path)
     FG_LOG_ENABLE && console.log('index:', index, path)
     // console.log('tabbarList:', tabbarList)