From fd9ba025ee3c974809e524d38c433b8ff0972d9c Mon Sep 17 00:00:00 2001 From: qiang Date: Sun, 20 Oct 2019 11:55:53 +0800 Subject: [PATCH] =?UTF-8?q?fix:=20=E8=B0=83=E6=95=B4=20nvue=20=E9=A1=B5?= =?UTF-8?q?=E9=9D=A2=20uni.setTabBarStyle=20borderStyle=20=E9=A2=9C?= =?UTF-8?q?=E8=89=B2?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../app-plus/service/api/ui/tab-bar.js | 27 ++++++++++++++----- .../app-plus/service/framework/tab-bar.js | 12 +++++---- 2 files changed, 28 insertions(+), 11 deletions(-) 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 88dd63224..22354b0b0 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 ead207d97..098d50c1f 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 的整体样式 -- GitLab