提交 57877d5f 编写于 作者: Q qiang

feat: uni.setTabBarItem 支持 pagePath 配置(App、H5)

上级 7c234e52
......@@ -18,6 +18,9 @@ export const setTabBarItem = {
},
selectedIconPath: {
type: String
},
pagePath: {
type: String
}
}
......
......@@ -19,14 +19,21 @@ export function setTabBarItem ({
index,
text,
iconPath,
selectedIconPath
selectedIconPath,
pagePath
}) {
if (!isTabBarPage()) {
return {
errMsg: 'setTabBarItem:fail not TabBar page'
tabBar.setTabBarItem(index, text, iconPath, selectedIconPath)
const route = pagePath && __uniRoutes.find(({ path }) => path === pagePath)
if (route) {
const meta = route.meta
meta.isTabBar = true
meta.tabBarIndex = index
meta.isQuit = true
const tabBar = __uniConfig.tabBar
if (tabBar && tabBar.list && tabBar.list[index]) {
tabBar.list[index].pagePath = pagePath.startsWith('/') ? pagePath.substring(1) : pagePath
}
}
tabBar.setTabBarItem(index, text, iconPath, selectedIconPath)
return {
errMsg: 'setTabBarItem:ok'
}
......
......@@ -43,9 +43,22 @@ function setTabBar (type, args = {}) {
case 'hideTabBar':
app.$children[0].hideTabBar = true
break
case 'setTabBarItem':
case 'setTabBarItem': {
setProperties(tabBar.list[index], setTabBarItemProps, args)
const pagePath = args.pagePath
const route = pagePath && __uniRoutes.find(({ path }) => path === pagePath)
if (route) {
const meta = route.meta
meta.isTabBar = true
meta.tabBarIndex = index
meta.isQuit = true
const tabBar = __uniConfig.tabBar
if (tabBar && tabBar.list && tabBar.list[index]) {
tabBar.list[index].pagePath = pagePath.startsWith('/') ? pagePath.substring(1) : pagePath
}
}
break
}
case 'setTabBarStyle':
setProperties(tabBar, setTabBarStyleProps, args)
break
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册