注册ID
https://mp.weixin.qq.com/cgi-bin/wx
下载开发工具以及小程序的API
https://developers.weixin.qq.com/miniprogram/dev/devtools/download.html
app.json 用来对微信小程序的进行全局配置,决定页面文件的路径、窗口表现、设置网络超时时间、设置多tab 等。
具体内容可以查看api https://developers.weixin.qq.com/miniprogram/dev/framework/app-service/app.html
{
{
"pages":[
"pages/index/index",
"pages/logs/logs"
],
"window":{
"backgroundTextStyle":"light",
"navigationBarBackgroundColor": "#fff",
"navigationBarTitleText": "WeChat",
"navigationBarTextStyle":"black"
}
"tabBar": {
"color": "#000000",
"selectedColor": "red",
"list":[
{
"pagePath":"pages/index/index",
"text":"首页"
},{
"pagePath": "pages/logs/logs",
"text": "日志"
}
]
}
}
}
Page /index 首页 一个文件夹包含三个文件 .js .wxml .wxss 一个文件夹代表一个页面
Window 设置导航栏格式
TabBar
底部
页面编写,文件名需要与文件夹一致, .js文件需要有page({
data: {
logs: []
},
onLoad: function () {
this.setData({
logs: (wx.getStorageSync('logs') || []).map(log => {
return util.formatTime(new Date(log))
})
})
}
})
App.js
myData:{
username:"wuduanqu"
},
Index.js
this.setData({motto:app.myData.username});
将在app取到的全局值赋值给motto