UNPKG

@morjs/runtime-web

Version:
26 lines 1.54 kB
"use strict"; Object.defineProperty(exports, "__esModule", { value: true }); exports.initTabBar = void 0; const helper_1 = require("./helper"); const url_1 = require("./url"); function initTabBar(config) { var _a, _b, _c, _d, _e, _f, _g, _h; // 支持业务配置多种TabBar,并且可以在运行阶段通过链接中的自定义的tabbarKey切换tabBar配置 const { customTabBarKey = 'tabBarKey' } = window.$MOR_APP_CONFIG || {}; const tabBarKey = ((_a = (0, url_1.getOptions)()) === null || _a === void 0 ? void 0 : _a[customTabBarKey]) || 'tabBar'; // 缓存 tabBar 路径,方便后续实现 switchTab 取值使用 (0, helper_1.cacheTabBarPath)(config.tabBar); if (!config[tabBarKey]) return; const tabBar = document.createElement('tiga-tabbar'); tabBar.conf = config[tabBarKey]; tabBar.conf.mode = (_c = (_b = config.router) === null || _b === void 0 ? void 0 : _b.mode) !== null && _c !== void 0 ? _c : 'browser'; tabBar.conf.homePage = (_d = config.pages) === null || _d === void 0 ? void 0 : _d[0]; tabBar.conf.customRoutes = (_f = (_e = config.router) === null || _e === void 0 ? void 0 : _e.customRoutes) !== null && _f !== void 0 ? _f : {}; tabBar.conf.baseName = (_h = (_g = config.router) === null || _g === void 0 ? void 0 : _g.baseName) !== null && _h !== void 0 ? _h : ''; const container = document.getElementById('container'); if (container) container.appendChild(tabBar); } exports.initTabBar = initTabBar; //# sourceMappingURL=tabbar.js.map