- 下面有三个文件 app.js 、index.js 、app.json
App({
onLaunch: function (options) {
console.log("app.js ---onLaunch---");
},
onShow: function () {
console.log("app.js ---onShow---");
},
onHide: function () {
console.log("app.js ---onHide---");
},
onError: function (msg) {
console.log("app.js ---onError---");
},
globalData: {
userInfo: null
}
})
Page({
data: {
},
onLoad: function (options) {
console.log("index.js ---onLoad---");
},
onReady: function () {
console.log("index.js ---onReady---");
},
onShow: function () {
console.log("index.js ---onShow---");
},
onHide: function () {
console.log("index.js ---onHide---");
},
onUnload: function () {
console.log("index.js ---onUnload---");
},
onPullDownRefresh: function () {
console.log("index.js ---onPullDownRefresh---");
},
onReachBottom: function () {
console.log("index.js ---onReachBottom---");
},
onShareAppMessage: function () {
console.log("index.js ---onShareAppMessage---");
}
})
{
"pages":[
"pages/index/index"
],
"window":{
"backgroundTextStyle":"light",
"navigationBarBackgroundColor": "#fff",
"navigationBarTitleText": "WeChat",
"navigationBarTextStyle":"black"
}
}
- 页面加载时console输出生命周期的状态
- 切后台时控制台输出生命周期状态
- 切回前台生命周期状态