


The content of this article is about WeChat applet examples: code implementation of click events and long press events. It has certain reference value. Friends in need can refer to it. I hope it will be helpful to you.
<button bindtouchstart="handleTouchStart" bindtouchend="handleTouchEnd" bindlongpress="handleLongPress" bindtap="handleClick"> 点击/长按</button> <!-- button 可以换成view-->
//touch start handleTouchStart: function(e) { this.startTime = e.timeStamp; //console.log(" startTime = " + e.timeStamp); }, //touch end handleTouchEnd: function(e) { this.endTime = e.timeStamp; //console.log(" endTime = " + e.timeStamp); }, handleClick: function(e) { //console.log("endTime - startTime = " + (this.endTime - this.startTime)); if (this.endTime - this.startTime < 350) { console.log("点击"); } }, handleLongPress: function(e) { //console.log("endTime - startTime = " + (this.endTime - this.startTime)); console.log("长按"); },
Related recommendations:
How to clear the default styles of buttons and scroll bars in mini programs (code)
json in WeChat mini programs Introduction to configuration configuration methods (with code)
The above is the detailed content of WeChat Mini Program Example: Code Implementation of Click Events and Long Press Events. For more information, please follow other related articles on the PHP Chinese website!

Hot AI Tools

Undresser.AI Undress
AI-powered app for creating realistic nude photos

AI Clothes Remover
Online AI tool for removing clothes from photos.

Undress AI Tool
Undress images for free

Clothoff.io
AI clothes remover

AI Hentai Generator
Generate AI Hentai for free.

Hot Article

Hot Tools

SAP NetWeaver Server Adapter for Eclipse
Integrate Eclipse with SAP NetWeaver application server.

Dreamweaver Mac version
Visual web development tools

ZendStudio 13.5.1 Mac
Powerful PHP integrated development environment

Atom editor mac version download
The most popular open source editor

SublimeText3 Linux new version
SublimeText3 Linux latest version
