页面Page是object
Page({
data:{
String1
},
onLoad:function(options){
// 生命周期函数--监听页面加载
- 一个页面只会调用一次。
- 接收页面参数可以获取
wx.navigateTo
和wx.redirectTo
及<navigator/>
中的 query。
String2
},
onReady:function(){
// 生命周期函数--监听页面初次渲染完成
一个页面只会调用一次,代表页面已经准备妥当,可以和视图层进行交互。
对界面的设置如wx.setNavigationBarTitle
请在onReady
之后设置
String3
},
onShow:function(){
// 生命周期函数--监听页面显示
每次打开页面都会调用一次。
String4
},
onHide:function(){
// 生命周期函数--监听页面隐藏
当navigateTo
或底部tab
切换时调用。
String5
},
onUnload:function(){
// 生命周期函数--监听页面卸载
当redirectTo
或navigateBack
的时候调用。
String6
},
onPullDownRefresh: function() {
// 页面相关事件处理函数--监听用户下拉动作
- 需要在
config
的window
选项中开启enablePullDownRefresh
。 - 当处理完数据刷新后,
wx.stopPullDownRefresh
可以停止当前页面的下拉刷新。
String7
},
onReachBottom: function() {
// 页面上拉触底事件的处理函数
String8
},
onShareAppMessage: function() {
// 用户点击右上角分享
- 只有定义了此事件处理函数,右上角菜单才会显示“分享”按钮
- 用户点击分享按钮的时候会调用
- 此事件需要 return 一个 Object,用于自定义分享内容
return {
title: 'title', // 分享标题
desc: 'desc', // 分享描述
path: 'path' // 分享路径
}
}
})