在编写微信小程序项目时,一开始为了显示出页面样式,我在app.json中,tabBar导航栏的list中设置了三个数组,对应三个导航块。但是三个导航块list中的pagePath设置为同一页面pagePath
"tabBar": {
"color": "#0094ff",
"selectedColor": "#ff9400",
"backgroundColor": "white",
"borderStyle": "black",
"position": "bottom",
"list": [
{
"text": "商品",
"pagePath": "pages/index/index",
"iconPath": "icon/good.png",
"selectedIconPath": "icon/selectedGood.png"
},
{
"text": "服务",
"pagePath": "pages/index/index",
"iconPath": "icon/serve.png",
"selectedIconPath": "icon/selectedServe.png"
},
{
"text": "我的",
"pagePath": "pages/index/index",
"iconPath": "icon/mine.png",
"selectedIconPath": "icon/selectedMine.png"
}
]
}
如上代码所示,如此在微信小程序开发工具中,PC端预览看到的页面导航栏并没有问题,显示出了三个导航块,点击每个导航块都是索引到index页面
但是,当尝试在手机端预览查看,仅显示了一个导航块,如图
而且,显示的导航块为最后一个“我的”部分。
在代码中没有发现其他问题,本人猜测:
当在tabBar导航栏中索引到多个数组,对应相同的pagePath时,在手机仅显示出最后一个索引该pagePath的导航块。
没有找到更合适的解决方法,以后还是尽量不要将多个导航块索引到同一个pagePath吧