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
Table of contents Business requirements: Solution...
Table of contents MySQL result sorting - Aggregat...
Table of contents cache Cache location classifica...
Download from official website: https://www.mysql...
First configure the project artifacts Configuring...
Query the current date SELECT CURRENT_DATE(); SEL...
1. Create a runner container mk@mk-pc:~/Desktop$ ...
1. Pull the image docker pull registry.cn-hangzho...
This article example shares the specific code of ...
Table of contents Written in front Requirements A...
Error message: Job for mysqld.service failed beca...
Table of contents Docker deployment Always on clu...
Table of contents Preface: Ubuntu 18.04 changes a...
"We're writing our next set of mobile pr...
Flash file formats: .FLV and .SWF There are two ex...