前两周很忙碌的边学就边做项目了,时间很赶,还没好好的总结一下,开发的时候自己就首先去看了小程序的API和对其目录结构的了解以及其工具的使用。
在了解完这些后开始进行对小程序开发的设计进行了大体的规划及搭建,其实小程序跟Android界面设计基本都那样。
好了,就从自己搭建项目开始的每个小块进行开始。
下面是对“tabBar”的简单应用,小程序API也可以直接进行拷贝复制小程序API 的https://mp.weixin.qq.com/debug/wxadoc/dev/framework/config.html
起码在复制后观看效果才能激发你的兴趣。其实API对这已经描述的很清楚的了,
tabBar
如果我们的小程序是一个多 tab 应用(客户端窗口的底部或顶部有 tab 栏可以切换页面),那么我们可以通过 tabBar 配置项指定 tab 栏的表现,以及 tab 切换时显示的对应页面。
Tip:
- 当设置 position 为 top 时,将不会显示 icon
- tabBar 中的 list 是一个数组,只能配置最少2个、最多5个 tab,tab 按数组的顺序排序。
属性说明:
属性 | 类型 | 必填 | 默认值 | 描述 |
---|---|---|---|---|
color | HexColor | 是 | tab 上的文字默认颜色 | |
selectedColor | HexColor | 是 | tab 上的文字选中时的颜色 | |
backgroundColor | HexColor | 是 | tab 的背景色 | |
borderStyle | String | 否 | black | tabbar上边框的颜色, 仅支持 black/white |
list | Array | 是 | tab 的列表,详见 list 属性说明,最少2个、最多5个 tab | |
position | String | 否 | bottom | 可选值 bottom、top |
其中 list 接受一个数组,数组中的每个项都是一个对象,其属性值如下:
属性 | 类型 | 必填 | 说明 |
---|---|---|---|
pagePath | String | 是 | 页面路径,必须在 pages 中先定义 |
text | String | 是 | tab 上按钮文字 |
iconPath | String | 否 | 图片路径,icon 大小限制为40kb,建议尺寸为 81px * 81px,当 postion 为 top 时,此参数无效 |
selectedIconPath | String | 否 | 选中时的图片路径,icon 大小限制为40kb,建议尺寸为 81px * 81px ,当 postion 为 top 时,此参数无效 |
下面为自己直接应用的,
app.json
{
"pages":[
"pages/index/index",
"pages/logs/logs",
"pages/test/test",
"pages/mine/mine"
],
"window":{
"backgroundTextStyle":"light",
"navigationBarBackgroundColor": "#fff",
"navigationBarTitleText": "WeChat",
"navigationBarTextStyle":"black"
},
"tabBar":{
"list":[{
"pagePath":"pages/index/index",
"selectedIconPath":"images/111.png",
"iconPath":"images/11.png",
"text":"首页"
},
{
"pagePath": "pages/logs/logs",
"selectedIconPath": "images/111.png",
"iconPath": "images/11.png",
"text": "日志"
},
{
"pagePath": "pages/test/test",
"selectedIconPath": "images/111.png",
"iconPath": "images/11.png",
"text": "测试"
},
{
"pagePath":"pages/mine/mine",
"selectedIconPath": "images/111.png",
"iconPath": "images/11.png",
"text": "我的"
}
]
}
}