diff --git a/packages/webpack-uni-pages-loader/lib/platforms/app-plus/index.js b/packages/webpack-uni-pages-loader/lib/platforms/app-plus/index.js index 27a2fea8e865c4220a145871bd63b982ea6aec2b..142bcd461008999ae62dea6ee9f9aaf8a6f8ef94 100644 --- a/packages/webpack-uni-pages-loader/lib/platforms/app-plus/index.js +++ b/packages/webpack-uni-pages-loader/lib/platforms/app-plus/index.js @@ -390,17 +390,18 @@ module.exports = function (pagesJson, userManifestJson) { } else if (isNVueEntryPage) { // 非纯 nvue 项目首页为 nvue 页面 manifestJson.plus.launchwebview.id = '2' + manifestJson.plus.launchwebview.render = 'always' } // 带 tab if (pagesJson.tabBar && pagesJson.tabBar.list && pagesJson.tabBar.list.length) { const tabBar = manifestJson.plus.tabBar = Object.assign({}, pagesJson.tabBar) const borderStyles = { - black: 'rgba(0,0,0,0.8)', - white: 'rgba(255,255,255,0.8)' + black: 'rgba(0,0,0,0.4)', + white: 'rgba(255,255,255,0.4)' } let borderStyle = tabBar.borderStyle if (!borderStyle) { - borderStyle = borderStyles.black + borderStyle = 'black' } if (borderStyle in borderStyles) { tabBar.borderStyle = borderStyles[borderStyle] diff --git a/src/platforms/app-plus/service/api/ui/tab-bar.js b/src/platforms/app-plus/service/api/ui/tab-bar.js index 88dd632240c2925d67a148ba26aefef81197125e..22354b0b09b97a72f09ece9a44e2c5177c2b7ccd 100644 --- a/src/platforms/app-plus/service/api/ui/tab-bar.js +++ b/src/platforms/app-plus/service/api/ui/tab-bar.js @@ -43,12 +43,27 @@ export function setTabBarStyle ({ errMsg: 'setTabBarStyle:fail not TabBar page' } } - tabBar.setTabBarStyle({ - color, - selectedColor, - backgroundColor, - borderStyle: borderStyle === 'white' ? '#ffffff' : '#c6c6c6' - }) + const style = {} + const borderStyles = { + black: 'rgba(0,0,0,0.4)', + white: 'rgba(255,255,255,0.4)' + } + if (color) { + style.color = color + } + if (selectedColor) { + style.selectedColor = selectedColor + } + if (backgroundColor) { + style.backgroundColor = backgroundColor + } + if (borderStyle in borderStyles) { + borderStyle = borderStyles[borderStyle] + } + if (borderStyle) { + style.borderStyle = borderStyle + } + tabBar.setTabBarStyle(style) return { errMsg: 'setTabBarStyle:ok' } diff --git a/src/platforms/app-plus/service/framework/tab-bar.js b/src/platforms/app-plus/service/framework/tab-bar.js index ead207d978e29c600971521c0b2c35eef3dde454..098d50c1f234c8d9de8f1bc30f72d587731a7156 100644 --- a/src/platforms/app-plus/service/framework/tab-bar.js +++ b/src/platforms/app-plus/service/framework/tab-bar.js @@ -50,17 +50,19 @@ function setTabBarBadge (type, index, text) { * 动态设置 tabBar 某一项的内容 */ function setTabBarItem (index, text, iconPath, selectedIconPath) { - const item = {} + const item = { + index + } + if (text !== undefined) { + item.text = text + } if (iconPath) { item.iconPath = getRealPath(iconPath) } if (selectedIconPath) { item.selectedIconPath = getRealPath(selectedIconPath) } - tabBar && tabBar.setTabBarItem(Object.assign({ - index, - text - }, item)) + tabBar && tabBar.setTabBarItem(item) } /** * 动态设置 tabBar 的整体样式