标签:updating variable 回调 and func href something span otto
1,App()
App() 必须在 app.js
中调用,必须调用且只能调用一次。不然会出现无法预期的后果
App({ onLaunch (options) { // Do something initial when launch. }, onShow (options) { // Do something when show. }, onHide () { // Do something when hide. }, onError (msg) { console.log(msg) }, globalData: ‘www.cnmibee.com‘
})
2,getApp()
App()
内的函数中,或调用 App
前调用 getApp()
,使用 this
就可以拿到 app 实例。getApp()
获取实例之后,不要私自调用生命周期函数。3,
Page(Object object)
注册小程序中的一个页面。接受一个 Object
类型参数,其指定页面的初始数据、生命周期回调、事件处理函数等。
Page({
data: {
text: "This is page data."
},
onLoad: function(options) {
// Do some initialize when page load.
},
onShow: function() {
// Do something when page show.
},
onReady: function() {
// Do something when page ready.
},
onHide: function() {
// Do something when page hide.
},
onUnload: function() {
// Do something when page close.
},
onPullDownRefresh: function() {
// Do something when pull down.
},
onReachBottom: function() {
// Do something when page reach bottom.
},
onShareAppMessage: function () {
// return custom share data when user share.
},
onPageScroll: function() {
// Do something when page scroll
},
onResize: function() {
// Do something when page resize
},
onTabItemTap(item) {
console.log(item.index)
console.log(item.pagePath)
console.log(item.text)
},
// Event handler.
viewTap: function() {
this.setData({
text: ‘Set some data for updating view.‘
}, function() {
// this is setData callback
})
},
customData: {
hi: ‘www.cnmibee.com‘
}
})
获取当前页面栈。数组中第一个元素为首页,最后一个元素为当前页面。
微信开发第四课 App() getApp() Page() getCurrentPages() 之间的区别
标签:updating variable 回调 and func href something span otto
原文地址:https://www.cnblogs.com/96net/p/12944586.html