


The WeChat applet monitors the user's sliding up or down method: first define the hidden used by the two modules that need to be switched; then define two variables in the data to accept the changed true or false; then use the data data It is used to determine whether the module displays hidden variables; finally, it is enough to collect the monitoring results.
Methods for WeChat applet to monitor whether the user slides up or down:
Idea: first monitor whether the user slides up or down It is still sliding. After listening to the results, change the variables in the data data used to determine whether the module is displayed or hidden. The two modules that need to be switched use hidden. Two variables are defined in the data to accept the changed true or false.
The code is:
hidden='{{bottom}}' hidden='{{top}}' data{ //初始化状态 top:true, bottom:false, } //判断浏览器滚动条上下滚动 if (t.scrollTop > a.data.scrollTop || t.scrollTop == wx.getSystemInfoSync().windowHeight) { console.log('向下滚动'); // 改变显示隐藏的状态 a.setData({ bottom: true, top: false }) console.log(a.data.bottom) } else { console.log('向上滚动'); a.setData({ bottom: false, top: true }) console.log(a.data.bottom) }
Related learning recommendations: WeChat Mini Program Development Tutorial
The above is the detailed content of How does a WeChat applet monitor users' scrolling up or down?. 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

Video Face Swap
Swap faces in any video effortlessly with our completely free AI face swap tool!

Hot Article

Hot Tools

SecLists
SecLists is the ultimate security tester's companion. It is a collection of various types of lists that are frequently used during security assessments, all in one place. SecLists helps make security testing more efficient and productive by conveniently providing all the lists a security tester might need. List types include usernames, passwords, URLs, fuzzing payloads, sensitive data patterns, web shells, and more. The tester can simply pull this repository onto a new test machine and he will have access to every type of list he needs.

WebStorm Mac version
Useful JavaScript development tools

Atom editor mac version download
The most popular open source editor

EditPlus Chinese cracked version
Small size, syntax highlighting, does not support code prompt function

DVWA
Damn Vulnerable Web App (DVWA) is a PHP/MySQL web application that is very vulnerable. Its main goals are to be an aid for security professionals to test their skills and tools in a legal environment, to help web developers better understand the process of securing web applications, and to help teachers/students teach/learn in a classroom environment Web application security. The goal of DVWA is to practice some of the most common web vulnerabilities through a simple and straightforward interface, with varying degrees of difficulty. Please note that this software