UNPKG

1.15 kBJavaScriptView Raw
1// @ts-nocheck
2import { initTabBarApis } from '@tarojs/taro';
3import { history } from './history';
4export function initTabbar(config) {
5 if (config.tabBar == null) {
6 return;
7 }
8 // TODO: custom-tab-bar
9 const tabbar = document.createElement('taro-tabbar');
10 const homePage = config.entryPagePath || (config.pages ? config.pages[0] : '');
11 tabbar.conf = config.tabBar;
12 tabbar.conf.homePage = history.location.pathname === '/' ? homePage : history.location.pathname;
13 const routerConfig = config.router;
14 tabbar.conf.mode = routerConfig && routerConfig.mode ? routerConfig.mode : 'hash';
15 if (routerConfig.customRoutes) {
16 tabbar.conf.custom = true;
17 tabbar.conf.customRoutes = routerConfig.customRoutes;
18 }
19 else {
20 tabbar.conf.custom = false;
21 tabbar.conf.customRoutes = {};
22 }
23 if (typeof routerConfig.basename !== 'undefined') {
24 tabbar.conf.basename = routerConfig.basename;
25 }
26 const container = document.getElementById('container');
27 container === null || container === void 0 ? void 0 : container.appendChild(tabbar);
28 initTabBarApis(config);
29}