当前位置:网站首页>Unapp prevents continuous click errors
Unapp prevents continuous click errors
2022-07-27 13:31:00 【Be nice 123】
- Create a... In the root directory of the project common Folder , And page Folder level , stay common Create a common.js file
common.js The contents of the document are as follows :
// Handle multiple hits
function noMultipleClicks(methods, info) {
// methods It is a function that needs to be executed after clicking , info Is to click the parameters to wear
let that = this;
if (that.noClick) {
// First click
that.noClick= false;
if(info !== ''){
// info Is the parameter that needs to be passed to execute the function
methods(info);
}else{
methods();
}
setTimeout(()=> {
that.noClick= true;
}, 1300)
} else {
console.log(" please 1.3s Then click ");// Here is the judgment of repeated clicks
}
}
// export
export default {
noMultipleClicks,// Multiple clicks are prohibited
}
- With the page Folder level main.js The following is introduced in the document :
Remember in data Mount in noClick:true,
// Configure public methods
import common from './common/common.js'
Vue.prototype.$noMultipleClicks = common.noMultipleClicks;
- Use in the page you want , With no arguments , Just send a method directly
// Remember in data Mount in noClick:true
data() {
return {
noClick:true,
}
},
<view class="bottom-btn-box">
<view class="submit-btn" @click="$noMultipleClicks(commitWork)"> Submit </view>
</view>
methods:{
commitWork(){
console.log("ahhhhh");
}
}
- Quote in the page you want to use , With parameters , Just pass a method and a parameter
Remember in data Mount in noClick:true,
// Remember in data Mount in noClick:true
data() {
return {
noClick:true,
}
},
<view class="bottom-btn-box">
<view class="pay" @click.stop="$noMultipleClicks(goPay, item)" > payment </view>
</view>
methods:{
goPay(item) {
console.log(item)
// Start your show
}
}
边栏推荐
- 最新版泛域名证书申请
- 基于frp实现内网穿透——借助公网服务器实现ssh远程连接内网服务器
- 高度塌陷最终解决方案(无副作用)
- A survey of video game addictive behavior research
- Feign的整体流程
- Hierarchy of elements
- Is it easy to find a job after programmer training and learning
- 附加:【URLEncoder.encode(待编码字符串, “编码方式“);】(是什么?;我们向cookie中设置值的时候,为什么要使用这个去编码?)(待完善……)
- 写出一个程序,接受一个有字母和数字以及空格组成的字符串,和一个字符,然后输出输入字符串中含有该字符的个数。不区分大小写。
- Reptile
猜你喜欢

能说一说 Kotlin 中 lateinit 和 lazy 的区别吗?

v-text

责任链模式在转转精准估价中的应用

@Simple understanding and use of conditionalonproperty

面试官常问:如何手撸一个“消息队列”和“延迟消息队列”?

Initializing database error after reinstalling MySQL

双料第一!

Musk was exposed to be the founder of Google: he broke up his best friend's second marriage and knelt down to beg for forgiveness

滑环设备怎么进行维护

W3school navigation bar exercise
随机推荐
18. Text processing tool -grep
电气成套企业如何借助ERP系统,做好成本利润管理?
Initializing database error after reinstalling MySQL
Intranet penetration based on FRP -- SSH Remote connection to intranet server with the help of public server
[nuxt 3] (XII) project directory structure 2
The role of Clearfix
完美指南|如何使用 ODBC 进行无代理 Oracle 数据库监控?
责任链模式在转转精准估价中的应用
图标字体
Open source project - taier1.2 release, new workflow, tenant binding simplification and other functions
Insert sort, positive order, reverse order
From the perspective of it, the CIO of B2B industry talks about how to change from "cost center" to "growth center"?
2022年7月24日 暑假第二周训练
利用eBPF探测Rootkit漏洞
Interview site: three kinds of questions
Feign client automatic assembly of three clients
力扣 1480. 一维数组的动态和 383. 赎金信412. Fizz Buzz
计算字符串最后一个单词的长度,单词以空格隔开。
Xshell7 can log in to MySQL virtual machine, but not mysql
7-16 daily sword finger offer II 041. Average value of sliding window