Skip to content

Commit

Permalink
fix(h5): tabbar init error #7290
Browse files Browse the repository at this point in the history
  • Loading branch information
ZakaryCode committed Sep 15, 2020
1 parent c8ce8bf commit d08f5f6
Show file tree
Hide file tree
Showing 2 changed files with 5 additions and 1 deletion.
3 changes: 2 additions & 1 deletion packages/taro-components/src/components/tabbar/tabbar.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -43,6 +43,7 @@ export interface Conf {
customRoutes: Record<string, string>
mode: 'hash' | 'browser'
basename: string
homePage: string
currentPagename: string
}

Expand Down Expand Up @@ -91,7 +92,7 @@ export class Tabbar implements ComponentInterface {
throw new Error('tabBar 配置错误')
}

this.homePage = addLeadingSlash(this.homePage)
this.homePage = addLeadingSlash(this.conf.homePage)
for (const key in customRoutes) {
this.customRoutes.push([key, customRoutes[key]])
}
Expand Down
3 changes: 3 additions & 0 deletions packages/taro-router/src/tabbar.ts
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
import { AppConfig } from '@tarojs/taro'
import { history } from './history'

export function initTabbar (config: AppConfig) {
if (config.tabBar == null) {
Expand All @@ -7,7 +8,9 @@ export function initTabbar (config: AppConfig) {

// TODO: 找到 tabbar 的类型
const tabbar = document.createElement('taro-tabbar') as any
const homePage = config.pages ? config.pages[0] : ''
tabbar.conf = config.tabBar
tabbar.conf.homePage = history.location.pathname === '/' ? homePage : history.location.pathname
const routerConfig = (config as any).router
tabbar.conf.mode = routerConfig && routerConfig.mode ? routerConfig.mode : 'hash'
const container = document.getElementById('container')
Expand Down

0 comments on commit d08f5f6

Please sign in to comment.