标签页要在 app.json 中设定 tabBar 配置项,有几个属性可以更改其外观,其中最主要的是 list,Array类型,在此指定标签页,另外,position 可指定卷标导航的位置是在底部 (bottom) 或上面 (top),默认值为 bottom。
标签导航页最多5个,最少2个,标签页按数组的顺序排列。每个页签要设定:
pagePath : 页面的路径,就是切换后要执行哪个 Page。
Text : 卷标页上按钮的文字。
iconPath : 卷标页上 icon的路径。图片大小限制为 40 KB。
selectedIconPath : 选中卷标时的 icon的路径。图片大小限制为 40 KB。
代码如下:
"tabBar": {
"list": [
{
"pagePath": "pages/index/index",
"text": "发现",
"iconPath": "images/bar/discover-0.png",
"selectedIconPath": "images/bar/discover-1.png"
},
{
"pagePath": "pages/subject/subject",
"text": "练习",
"iconPath": "images/bar/practice-0.jpg",
"selectedIconPath": "images/bar/practice-1.jpg"
},
{
"pagePath": "pages/mall/mall",
"text": "商城",
"iconPath": "images/bar/mall-0.png",
"selectedIconPath": "images/bar/mall-1.png"
},
{
"pagePath": "pages/me/me",
"text": "我",
"iconPath": "images/bar/me-0.png",
"selectedIconPath": "images/bar/me-1.png"
}
]
}