微信小程序配置详情
app页面配置
app窗口配置
app的tabBar配置
网络超时配置及debug开启配置
app.json(真实的项目中这个文件是不能出现注释的,否则会报错)
{
//创建页面
"pages":[
"pages/index/index",
"pages/logs/logs"
],
//配置窗口显示
"window":{
"backgroundTextStyle":"light",
"navigationBarBackgroundColor": "#222",
"navigationBarTitleText": "配置文件",
"navigationBarTextStyle":"#fff"
},
//配置底部的tab
"tabBar": {
"color":"#ccc",
"borderStyle":"#dfdfdf",
"list": [{
"pagePath": "pages/index/index",
"text": "首页",
"iconPath":"images/icon1.png",
"selectedIconPath":"images/icon1s.png"
}, {
"pagePath": "pages/logs/logs",
"text": "日志",
"iconPath":"images/icon2.png",
"selectedIconPath":"images/icon2s.png"
}]
},
//设置网络超时
"networkTimeout": {
"request": 10000,
"downloadFile": 10000
},
//开启debug
"debug": true
}
小程序的生命周期与app对象使用
跳转新页面
itemClick:function(){
wx.navigateTo({
url:"../login/login"
})
}
数据传递
1.通过添加点击事件
index.js发送js
itemClick : function (){
wx.navigateTo({
url:"../logs/logs?id=1"
})
}
logs.js接受js
onLoad:function(options){
this.setData({articleId:options.id}
}
2.直接用标签包裹
<navigator url="../logs/logs?id=100&title=标题" >
<view >
<text class="user-motto">文章1</text>
</view>
</navigator>
logs.js接受js
onLoad:function(options){
this.setData({articleId:options.id}
}
注意:app.json里面,tabBar里面的地址不能和跳转地址一样,会造成冲突