根据官方文档写的tabBar
-
先创建文件夹
- 图标:
images
文件夹下的icon
- 先删除原来
pages
文件夹下的页面 - 在重新在
pages
文件夹下新建四个页面,分别是:chat
:消息doc
:文档home
:首页profile
:我的
- 图标:
-
目录结构:
-
在每个页面文件夹下的
index.json
中,写入:"navigationBarTitleText": ""
,这样便于辨认tabBar
之间的切换。-
在
home
页面中的index.json
中{ "usingComponents": {}, "navigationBarTitleText": "首页" }
-
在
chat
页面中的index.json
中{ "usingComponents": {}, "navigationBarTitleText": "消息" }
-
在
doc
页面中的index.json
中{ "usingComponents": {}, "navigationBarTitleText": "文档" }
-
在
profile
页面中的index.json
中{ "usingComponents": {}, "navigationBarTitleText": "我的" }
-
-
最后在
app.json
中配置tabBar
{ "pages":[ "pages/home/index", "pages/doc/index", "pages/chat/index", "pages/profile/index" ], "window":{ "backgroundTextStyle":"light", "navigationBarBackgroundColor": "#fff", "navigationBarTitleText": "Weixin", "navigationBarTextStyle":"black" }, "tabBar": { "color": "#30c6c7", "selectedColor": "#fa8c57", "backgroundColor": "#f9f9f9", "borderStyle":"black", "position": "bottom", "list": [ { "pagePath": "pages/home/index", "text": "首页", "iconPath": "./images/icon/home.png", "selectedIconPath": "./images/icon/home_selected.png" }, { "pagePath": "pages/doc/index", "text": "文档", "iconPath": "./images/icon/document.png", "selectedIconPath": "./images/icon/document_selected.png" },{ "pagePath": "pages/chat/index", "text": "消息", "iconPath": "./images/icon/chat.png", "selectedIconPath": "./images/icon/chat_selected.png" },{ "pagePath": "pages/profile/index", "text": "我的", "iconPath": "./images/icon/user.png", "selectedIconPath": "./images/icon/user_selected.png" } ] }, "style": "v2", "sitemapLocation": "sitemap.json" }
-
页面展示效果