当前位置:网站首页>Prevent users from submitting repeatedly in the uniapp project
Prevent users from submitting repeatedly in the uniapp project
2022-06-23 18:09:00 【Lao Zhang taps the code online】
1. New in the root directory common File and create common.js file , Copy and paste the code directly .
// Prevent processing multiple clicks
function noMultipleClicks(methods, info) {
// methods It is a function that needs to be executed after clicking , info Is to click the parameter to be transmitted
let that = this;
if (that.noClick) {
// First click
that.noClick= false;
if(info && info !== '') {
// info Is the parameter that needs to be passed to execute the function
methods(info);
} else {
methods();
}
setTimeout(()=> {
that.noClick= true;
}, 2000)
} else {
// Here is the judgment of repeated clicks
}
}
// export
export default {
noMultipleClicks,// Multiple clicks are prohibited
}
2.man.js Introduce in the file
// Configure public methods
import common from './common/common.js'
Vue.prototype.$noMultipleClicks = common.noMultipleClicks;
3. Reference... In the actual page
(1) Don't pass it on , Just pass a method directly
// Remember in data Mount in noClick:true, Otherwise, clicking will fail
data() {
return {
noClick:true,
}
},
<view class="bottom-btn-box">
<view class="submit-btn" @click="$noMultipleClicks(commitWork)"> Submit </view>
</view>
methods:{
// Submission method
commitWork(){
}
}
(2) With parameters , Just pass a method and a parameter
// Remember in data Mount in noClick:true, Otherwise, clicking will fail
data() {
return {
noClick:true,
}
},
<view class="bottom-btn-box">
<view class="pay" @click.stop="$noMultipleClicks(goPay, item)" > payment </view>
</view>
methods:{
goPay(item){
//balabala
}
}
边栏推荐
- 6 steps to teach you financial data mining preprocessing
- What if the website is poisoned
- Thesis reading (53):universal advantageous perturbations
- How to make a badge
- [JS reverse hundred examples] pedata encryption information and zlib Application of gunzipsync()
- Also using copy and paste to create test data, try the data assistant!
- Crmeb second open SMS function tutorial
- Paper reading (47):dtfd-mil: double tier feature interpretation multiple instance learning for histopathology
- 【ESP8266-01s】獲取天氣,城市,北京時間
- Torch learning (I): environment configuration
猜你喜欢

【故障公告】取代 memcached 的 redis 出现问题造成网站故障
![[mae]masked autoencoders mask self encoder](/img/08/5ab2b0d5b81c723919046699bb6f6d.png)
[mae]masked autoencoders mask self encoder

Paper reading (54):deepfool: a simple and accurate method to four deep neural networks

【win10 VS2019 opencv4.6 配置参考】

正则表达式使用图床

org.apache.ibatis.binding.BindingException: Invalid bound statement (not found):...

Self training multi sequence learning with transformer for weakly supervised video animation

esp8266-01s 不能连接华为路由器解决方法

【Unity】插件TextAnimator 新手使用说明

Crmeb second open SMS function tutorial
随机推荐
Revil - blackmail Virus Emergency Response
CRMEB 二开短信功能教程
Paper reading (54):deepfool: a simple and accurate method to four deep neural networks
对抗攻击与防御 (1):图像领域的对抗样本生成
console. Log() is an asynchronous operation???
2022年在网上办理股票开户安全吗?
New function! Qianfan magic pen apaas December capability monthly report
论文阅读 (57):2-hydr_Ensemble: Lysine 2-Hydroxyisobutyrylation Identification with Ensemble Method (任务)
Thymeleaf - learning notes
Paper reading (55):dynamic multi robot task allocation under uncertainty and temporary constraints
[esp8266-01s] get weather, city, Beijing time
Similarities and differences between Chinese and American electronic signature SaaS
Counter attack and defense (2): counter strategy against samples
Redis ubuntu18.04.6 intranet deployment
Self training multi sequence learning with transformer for weakly supervised video animation
一元二次方程到规范场
论文阅读 (50):A Novel Matrix Game with Payoffs of Maxitive Belief Structure
手机开户一般哪个证券公司好?在线开户安全么?
[mae]masked autoencoders mask self encoder
org. apache. ibatis. binding. BindingException: Invalid bound statement (not found):...