当前位置:网站首页>【微信小程序】页面事件
【微信小程序】页面事件
2022-07-30 06:42:00 【热爱编程的小白白】
目录
小程序 - 视图与逻辑
页面导航 - 导航传参
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是 导航 传过来的参数对象
},
页面事件 - 下拉刷新事件
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('触发了上拉触底的事件')
},
3. 配置上拉触底距离
边栏推荐
- AutoSAR EcuM系列01- EcuM模块的功能概述和变体类型
- SE11 创建搜索帮助
- C语言自定义类型详解
- Interview with Ant: How do these technology pioneers do the bottom-level development well?| Excellent technical team interview
- DP5340 domestic replacement for CM5340 stereo audio A/D converter chip
- Go: go - redis based operation
- Portable small fan PD power chip
- interface
- ArrayList
- assert
猜你喜欢
LSF提交作业命令--bsub
Go语学习笔记 - gorm使用 - 数据库配置、表新增 Web框架Gin(七)
How to calculate the daily cumulative capital flow one by one in real time
golang : Zap log integration
SE11 创建搜索帮助
DP5340国产替代CM5340立体声音频A/D转换器芯片
BGP:边界网关路由协议 无类别的路径矢量EGP协议
【雷达目标检测】恒定阈值法和恒虚警(CFAR)法及代码实现
Charles通过Rewrite越过OPTIONS请求拦截
Go uses the mencached cache
随机推荐
「活动推荐」探索未来:数字科技
goto语句
Two Permutations(2022杭电杯)
实现定时器
动态规划专栏
Limit injection record of mysql injection in No. 5 dark area shooting range
雷总个人博客看到
C语言自定义类型详解
C language custom types, rounding
selenium模块
MySQL basics [naming convention]
使用navicat连接mysql数据库时常报的错误:2003、1698、1251
ES: 箭头函数和包裹它的代码共享相同的this
Handler消息机制-Native层
MySQL题外篇【ORM思想解析】
Map file analysis in Keil software
Go uses freecache for caching
redis多节点部署实施指引
interface
golang : Zap日志整合