当前位置:网站首页>【WeChat Mini Program】Page Events
【WeChat Mini Program】Page Events
2022-07-30 08:38:00 【Small white white love of programming】
目录
小程序 - 视图与逻辑
页面导航 - 导航传参
1. 声明式导航传参
- 参数与路径之间使用 ? 分隔
- 参数键与参数值用 = 相连
- 不同参数用 & 分隔
<navigator url="/pages/info/info?name=zs&age=20">跳转到info页面</navigator>
2. 编程式导航传参
<button bindtap="gotoInfo2">跳转到info页面</button>
gotoInfo2() {
wx.navigateTo({
url: '/pages/info/info?name=ls&gender=男'
})
},
3. 在 onLoad 中接收导航参数
/**
* 生命周期函数--监听页面加载
*/
onLoad: function (options) {
console.log(options)
//options是 导航 The passed parameter object
},
页面事件 - 下拉刷新事件
1. 什么是下拉刷新
2. 启用下拉刷新
3. 配置下拉刷新窗口的样式
4. 监听页面的下拉刷新事件

<view>count值是:{
{count}}</view>
<button bindtap="addCount">+1</button>
addCount() {
this.setData({
count: this.data.count + 1
})
},
在触发页面的下拉刷新事件的时候,如果要把 count 的值重置为 0,示例代码如下:
/**
* 页面相关事件处理函数--监听用户下拉动作
*/
onPullDownRefresh: function () {
this.setData({
count: 0
})
},
5. 停止下拉刷新的效果
/**
* 页面相关事件处理函数--监听用户下拉动作
*/
onPullDownRefresh: function () {
// console.log('触发了message页面的下拉刷新')
this.setData({
count: 0
})
//当数据重置成功后,调用此函数,关闭下拉刷新的效果
wx.stopPullDownRefresh()
},
页面事件 - 上拉触底事件
1. 什么是上拉触底
2. 监听页面的上拉触底事件
/**
* 页面上拉触底事件的处理函数
*/
onReachBottom: function () {
console.log('The pull-up bottoming event is triggered')
},
3. 配置上拉触底距离
边栏推荐
猜你喜欢
Handler消息机制-Native层
C# 获取系统已安装的.NET版本
用代码收集每天热点内容信息,并发送到自己的邮箱
入选“十大硬核科技”,详解可信密态计算(TECC)技术点
[GAN]老照片修复Bringing Old Photos Back to Life论文总结
typescript5 - compile and install ts code
SQL窗口函数
Interview with Ant: How do these technology pioneers do the bottom-level development well?| Excellent technical team interview
How to calculate the daily cumulative capital flow one by one in real time
「活动推荐」探索未来:数字科技
随机推荐
Two Permutations(2022杭电杯)
Risk Register
sql 引用变量时第一位的0被去除掉如何处理
SQL的substring_index()用法——MySQL字符串截取
【COCI 2020/2021 Round #2 D】Magneti(DP)
【BERT-多标签文本分类实战】之二——BERT的地位与名词术语解释
MySql详解基础
动态规划专栏
SQL行列转换
SOFA Weekly|Meetup 广州站、本周 QA、本周 Contributor
C语言自定义类型详解
Hex conversion...
mysql设置会话超时时间
Mybitatis related configuration files
【Codeforces Round #805 (Div. 3)(A~C)】
40.【vector的运用】
General Lei's personal blog to see
便携小风扇PD取电芯片
数据库连接池的使用
Interview with Ant: How do these technology pioneers do the bottom-level development well?| Excellent technical team interview