微信小程序文档:http://mp.weixin.qq.com
可以查看全局配置,页面配置,组件,API等内容
1.tabBar底部栏。
list 接受一个数组,只能配置最少 2 个、最多 5 个 tab。tab 按数组的顺序排序,每个项都是一个对象。在app.json文件中配置信息。
"tabBar": {
"color":"#aaa",
"selectedColor": "#f00",
"list":[{
"pagePath":"pages/index/index",
"text":"首页",
"iconPath":"images/index0.png",
"selectedIconPath": "images/index1.png"
},{
"pagePath":"pages/shop/shop",
"text":"购物车",
"iconPath":"images/shop0.png",
"selectedIconPath": "images/shop1.png"
},{
"pagePath":"pages/my/my",
"text":"我的",
"iconPath":"images/my0.png",
"selectedIconPath": "images/shop1.png"
}]
},
2.修改页面标题
① 修改全部页面的标题:设置app.json文件内的window的navigationBarTitleText。
每一个小程序页面也可以使用 .json 文件来对本页面的窗口表现进行配置。页面中配置项在当前页面会覆盖 app.json 的 window 中相同的配置项。文件内容为一个 JSON 对象。
② 修改子页面的标题:在shop.json文件中设置navigationBarTitleText
{
"navigationBarTitleText":"购物车",
"usingComponents": {
}
}
3.路由跳转
① API
wx.navigateTo(Object object):
保留当前页面,跳转到应用内的某个页面。但是不能跳到 tabbar 页面。使用 wx.navigateBack 可以返回到原页面。小程序中页面栈最多十层。
//shop.wxml
<button bindtap="turn">turn</button>
//shop.js turn()与data同级
turn(){
wx.navigateTo({
//url可带参数
url:"/pages/home/home?id=10"
});
},
//home.js页面onLoad页面加载阶段接收参数
onLoad: function (options) {
console.log(options.id)