小程序开发首页开发1Tabbar配置
tabbar配置,即设置页面跳转按钮和设置页面相应图标
pagepath 路由路径
text 页面提示
iconpath 图标路径
selectediconpath 选中图标路径
在list外 可以加个选中文字的颜色 selectedcolor :颜色
```
{
"pages": [
"pages/index/index",
"pages/logs/logs",
"pages/join/join"
],
"window": {
"backgroundTextStyle": "light",
"navigationBarBackgroundColor": "#fff",
"navigationBarTitleText": "WeChat",
"navigationBarTextStyle": "black"
},
"sitemapLocation": "sitemap.json",
"tabBar": {
"selectedColor": "#000",
"list": [{
"pagePath": "pages/index/index",
"text": "首页",
"iconPath": "images/bar.png",
"selectedIconPath": "images/bar_s.png"
},
{
"pagePath": "pages/join/join",
"text": "加入",
"iconPath": "images/joinin.png",
"selectedIconPath": "images/joinin_s.png"
}]
}
}
```
```
{
"pages": [
"pages/index/index",
"pages/logs/logs",
"pages/join/join"
],
"window": {
"backgroundTextStyle": "light",
"navigationBarBackgroundColor": "#fff",
"navigationBarTitleText": "WeChat",
"navigationBarTextStyle": "black"
},
"sitemapLocation": "sitemap.json",
"tabBar": {
"selectedColor": "#000",
"list": [{
"pagePath": "pages/index/index",
"text": "首页",
"iconPath": "images/bar.png",
"selectedIconPath": "images/bar_s.png"
},
{
"pagePath": "pages/join/join",
"text": "加入",
"iconPath": "images/joinin.png",
"selectedIconPath": "images/joinin_s.png"
}]
}
}
```
{
"pages": [
"pages/index/index",
"pages/logs/logs",
"pages/join/join"
],
"window": {
"backgroundTextStyle": "light",
"navigationBarBackgroundColor": "#fff",
"navigationBarTitleText": "WeChat",
"navigationBarTextStyle": "black"
},
"sitemapLocation": "sitemap.json",
"tabBar": {
"selectedColor": "#000",
"list": [{
"pagePath": "pages/index/index",
"text": "首页",
"iconPath": "images/bar.png",
"selectedIconPath": "images/bar_s.png"
},
{
"pagePath": "pages/join/join",
"text": "加入",
"iconPath": "images/joinin.png",
"selectedIconPath": "images/joinin_s.png"
}]
}
}
tarbar的配置使用
app.json中配置底部tarbar
{
"pages":[
"pages/index/index",
"pages/logs/logs"
],
"window":{
"backgroundTextStyle":"light",
"navigationBarBackgroundColor": "#fff",
"navigationBarTitleText": "第一个小程序",
"navigationBarTextStyle":"black"
},
"tabBar": {
"list": [{
"pagePath": "pages/index/index",
"text": "首页",
"iconPath": "images/index_tarbar1.png",
"selectedIconPath": "images/index_tarbar1_selected.png"
},{
"pagePath": "pages/index/index",
"text": "购物车",
"iconPath": "images/index_tarbar2.png",
"selectedIconPath": "images/index_tarbar2_selected.png"
}]
}
}
素材和源码地址,请查看github地址:https://github.com/lshxiao/myfirst
tabbar配置在app.json,输入回车自动带入进本设置项:
pagepath:页面路由;text:指图标之外的文字;
iconpath:指图标文件的地址;
selectediconpath:图标选中状态的地址;可以从目录硬盘打开那里去复制选中状态的图表名称;
配置好第一个tab以后复制一份,修改里面的配置内容;
设置选中状态的颜色:selectedcolor:"red"
素材和源码地址,请查看github地址:https://github.com/lshxiao/myfirst
按照视频写好tabbar后,没有出现图标。
查了半天,发现是模拟器页面太长,需要滚动鼠标到下方,才能看到tabbar的图标。
不过,因为查这个问题,有网友反映:
要加入到tabbar中的链接,必须包括pages:{
}的第一项。
即这里写的程序
"tabBar": {
"selectedColor": "#0f0",
"list": [{
"pagePath": "pages/index/index",
就包含了pages中的第一项:
{
"pages":[
"pages/index/index",
"pages/join/join",
"pages/logs/logs"
],
"pages/index/index",就是第一项,被包含在tabbar中。
tabbar 主菜单选项 ,
素材和源码地址,请查看github地址:https://github.com/lshxiao/myfirst
tabBar设置底部的导航栏