This article shares the specific code of the WeChat applet to achieve the shaking sieve effect for your reference. The specific content is as follows 1. Effect diagram: 2.HTML code: <!--pages/game/game.wxml--> <view class="text">The number of sieve points is: {{total}}</view> <view class="point1"> <image src="{{top}}"> </image> </view> <view class="point2"> <image src="{{left}}"></image> <image src="{{right}}"> </image> </view> <button class='{{btn}}' bindtap='click'>{{texts}}</button> 3.js code: data: { top: "../images/images/1-point.png", total: '', left: "../images/images/2-point.png", right: "../images/images/3-point.png", btn: '.btnStart', texts:'Shake it', flag: true, img:[ "../images/images/1-point.png", "../images/images/2-point.png", "../images/images/3-point.png", "../images/images/4-point.png", "../images/images/5-point.png", "../images/images/6-point.png" ] }, /** * Life cycle function--listen for page loading*/ click:function(){ var self = this; if(this.data.flag){ self.timer = setInterval(function(){ var one = Math.floor(Math.random() * 6); var two = Math.floor(Math.random() * 6); var three = Math.floor(Math.random() * 6); self.setData({ top: self.data.img[one], left: self.data.img[two], right: self.data.img[three], total:one+two+three+3, }) },200) self.setData({ btn: ".btnEnd", texts: 'Stop', flag:false, }) } else { clearInterval(self.timer); self.setData({ btn: ".btnStart", texts: 'Shake it', flag: true, }) } }, The above is the full content of this article. I hope it will be helpful for everyone’s study. I also hope that everyone will support 123WORDPRESS.COM. You may also be interested in:
|
<<: Tutorial on binary compilation and installation of MySql centos7 under Linux
>>: MySQL 5.7.23 decompression version installation tutorial with pictures and text
1. Dynamic Components <!DOCTYPE html> <h...
1. Preparation before installation Check the data...
Preface Recently I found that my friend's met...
MariaDB database management system is a branch of...
This article mainly introduces the method of conf...
Important data must be backed up, and must be bac...
Table of contents 1. Introduction 2. RC and RR is...
Table of contents Working principle: What does th...
Inserting images into HTML requires HTML tags to ...
Command: mysqlhotcopy This command will lock the ...
MySQL 8 brings a brand new experience, such as su...
Countdown function needs to be implemented in man...
Windows: Support NTFS, FAT Linux supports file fo...
1. CSS3 animation ☺CSS3 animations are much easie...
How to implement text icons through CSS /*icon st...