# [丸子社區(丸小圈)底部 tabBar 菜單修改教程](https://www.weitimes.com/doc/guide/1400.html#1400)
1、修改 app.json 的 “tabBar” 項中的 “list” 列表項。
~~~
"tabBar": {
"custom": true,
"color": "#3C3C3C",
"selectedColor": "#35495e",
"borderStyle": "black",
"backgroundColor": "#ffffff",
"list": [
{
"pagePath": "pages/tabbar/index/index",
"iconPath":"/image/home_d@3x.png",
"selectedIconPath":"/image/home_d@3x.png"
},
{
"pagePath": "pages/tabbar/circle/circle",
"iconPath":"/image/home_d@3x.png",
"selectedIconPath":"/image/home_d@3x.png"
},
{
"pagePath": "pages/tabbar/message/message",
"iconPath":"/image/home_d@3x.png",
"selectedIconPath":"/image/home_d@3x.png"
},
{
"pagePath": "pages/tabbar/mine/mine",
"iconPath":"/image/home_d@3x.png",
"selectedIconPath":"/image/home_d@3x.png"
}
]
},
~~~
注意:pagePath 頁面地址不能帶有參數,即不支持 pages/detail/detail?id=88 類似這種帶有問號參數的鏈接
2、修改 custom-tab-bar 目錄里的 index.js 的 “list” 對應的 pagePath 與 app.json 里的 “list” 對應的 pagePath 相同
~~~
data: {
selected: 0,
unReadMessageCount: 0,
sysMessageCount: 0,
color: "#B0A9A3",
selectedColor: "#2E2E2E",
fontWeight: "bold",
list: [{
pagePath: "/pages/tabbar/index/index",
iconPath: "/image/tabbar/tab_index_normal.png",
selectedIconPath: "/image/tabbar/tab_index_active.png",
text: "首頁"
}, {
pagePath: "/pages/tabbar/circle/circle",
iconPath: "/image/tabbar/tab_nearby_normal.png",
selectedIconPath: "/image/tabbar/tab_nearby_active.gif",
text: "圈子"
}, {
pagePath: "/pages/creat/creat",
iconPath: "/image/tabbar/icon_add.png",
selectedIconPath: "/image/tabbar/icon_add.png",
text: "",
isSpecial: !0
}, {
pagePath: "/pages/tabbar/message/message",
iconPath: "/image/tabbar/tab_message_normal.png",
selectedIconPath: "/image/tabbar/tab_message_active.png",
text: "消息"
}, {
pagePath: "/pages/tabbar/mine/mine",
iconPath: "/image/tabbar/tab_user_normal.png",
selectedIconPath: "/image/tabbar/tab_user_active.png",
text: "我的"
}]
},
~~~
注意:除了中間發布的按鈕,其他頁面的參數及順序必須一致。
3、修改指定 pagePath 頁面的 js 文件 onShow 函數加上對應內容
~~~
onShow: function () {
"function" == typeof this.getTabBar && this.getTabBar() && this.getTabBar().setData({
selected: 1
})
//其他代碼部分
},
~~~
注意:selected 的值是 custom-tab-bar/index.js 參數 “list” 對應的位置
假如你修改了消息位置為資訊,那么就要在資訊頁對應的 js 頁面,onShow 函數加上以下內容
~~~
"function" == typeof this.getTabBar && this.getTabBar() && this.getTabBar().setData({
selected: 3
})
~~~
因為,消息位置是在 custom-tab-bar/index.js 的 “list” 列表中屬于第 3 項(從 0 計算)。
另外,需要把對應的 message.js 里的 onShow 函數刪除上面的那部分內容。