当前位置:网站首页>【微信小程序2】事件绑定
【微信小程序2】事件绑定
2022-08-02 08:22:00 【m0_65431212】
什么是事件
事件:是渲染层到逻辑层的通讯方式
小程序常用的事件
| 类型 | 事件概述 |
|---|---|
| tap | 手指触摸后立刻离开,类似于HTML中的click事件 |
| input | 文本框的输入事件 |
| change | 状态改变时触发 |
事件对象的属性列表

红色:常用
target与currentTarget的区别
target是触发该事件的源头组件,而currentTarget是当前事件所绑定的组件。
举例如下:
bindtap的语法格式
- 通过bindtap,可以为组件绑定tap触摸事件,在.wxml文件中:
<button type="primary" bindtap="btnTapHandler">按钮</button>
- 在页面的.js文件中定义对应的事件处理函数,事件参数通过形参event(一般简写成e)来接受:
btnTapHandler(e){
console.log(e)
},
- 在调试器中可以查看相关的事件对象属性

边栏推荐
- Redisson报异常attempt to unlock lock, not locked by current thread by node id解决方案
- 【C】关于柔性数组.简要的谈谈柔性数组
- A young man with strong blood and energy actually became a housekeeper. How did he successfully turn around and change careers?
- 商业智能平台BI 商业智能分析平台 如何选择合适的商业智能平台BI
- 工程师如何对待开源 --- 一个老工程师的肺腑之言
- AI目标分割能力,无需绿幕即可实现快速视频抠图
- Biotin-EDA|CAS:111790-37-5| 乙二胺生物素
- postman下载安装汉化及使用
- The custom table form
- Button to control the running water light (timer)
猜你喜欢
![shell中计算命令详解(expr、(())、 $[]、let、bc )](/img/3c/5cc4d16b9b525997761445f32802d5.png)
shell中计算命令详解(expr、(())、 $[]、let、bc )

A young man with strong blood and energy actually became a housekeeper. How did he successfully turn around and change careers?

Biotin hydrazide HCl|CAS:66640-86-6|Biotin-hydrazide hydrochloride

【电子电路】长按键拉低电平,适用在有休眠机制的MCU但是没有看门狗,一个按键多个功能场景下使用

pnpm:简介

postman使用方法

OneNote Tutorial, How to Create More Spaces in OneNote?

Figure robot software digital twin station oil and gas pipelines, oil and gas transportation control platform
![[OC学习笔记]weak的实现原理](/img/39/d6183deda2a530b78a0883e0f60153.png)
[OC学习笔记]weak的实现原理

uvm-phase机制
随机推荐
PyCharm usage tutorial (more detailed, picture + text)
Detailed explanation of calculation commands in shell (expr, (()), $[], let, bc )
houdini 求出曲线的法向 切线以及副法线
QT web 开发 - 笔记 - 3
HCIP笔记第十三天
如何做好项目管理
JSP中page指令的import命令具有什么功能呢?
52. [Bool type input any non-0 value is not 1 version reason]
EPSANet: An Efficient Pyramid Split Attention Block on Convolutional Neural Network
postman使用方法
Installation and use of pnpm
Codeforces Round #811 (Div. 3)无DF
Redis分布式锁入门
Pycharm (1) the basic use of tutorial
Gorilla Mux 和 GORM 的使用方法
OneNote 教程,如何在 OneNote 中创建更多空间?
mysqldump --set-gtid-purged=OFF
Database triggers and transactions
Wang Xuegang - compiled shipment line file
Hikari连接池源码解读