当前位置:网站首页>【微信小程序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)
},
- 在调试器中可以查看相关的事件对象属性

边栏推荐
- 类和对象【下】
- 为什么都推荐使用wordpress, 而不是 phpcms 这些国内的CMS呢?
- etcd实现大规模服务治理应用实战
- 工程师如何对待开源 --- 一个老工程师的肺腑之言
- C语言_指针
- Redis分布式锁入门
- MySQL Workbench 安装及使用
- C语言_条件编译
- [OC学习笔记]weak的实现原理
- R language plotly visualization: use the plotly visualization model to predict the true positive rate (True positive) TPR and false positive rate (False positive) FPR curve under different thresholds
猜你喜欢

pnpm: Introduction

PyCharm usage tutorial (more detailed, picture + text)

PyQt5 (a) PyQt5 installation and configuration, read from the folder and display images, simulation to generate the sketch image

小康股份更名赛力斯,如何走出一条高端产品的“丝绸之路”?

(Note) AXIS ACASIS DT-3608 Dual-bay Hard Disk Array Box RAID Setting
![[OC学习笔记]ARC与引用计数](/img/56/033cfc15954567d63d987d91ca8d63.png)
[OC学习笔记]ARC与引用计数

postman使用方法
MySQL ODBC驱动简介

查看变量的数据格式

“蔚来杯“2022牛客暑期多校训练营4
随机推荐
二分类和多分类
Ansible 学习总结(11)—— task 并行执行之 forks 与 serial 参数详解
houdini 求出曲线的法向 切线以及副法线
redis-desktop-manager下载安装
MySQL ODBC驱动简介
EPSANet: An Efficient Pyramid Split Attention Block on Convolutional Neural Network
The custom table form
prometheus监控mysql_galera集群
Analysis of software testing technology How far is Turing test from us
王学岗-编译出运行的文件
ORBSLAM代码阅读
PyQt5(一) PyQt5安装及配置,从文件夹读取图片并显示,模拟生成素描图像
Button to control the running water light (timer)
pnpm: Introduction
那些年我们踩过的 Flink 坑系列
[OC学习笔记]weak的实现原理
查看变量的数据格式
What is NoSQL?Databases for the cloud-scale future
C语言_指针
Installation and use of pnpm