在微信小程序中,有自制對話框用於提交數據,但是會出現用戶連續點擊,多次提交數據的情況。
//.wxml
<view class="acertain" bindtap="{{dis?'acertain':''}}" >確定</view>
//.js
//在 data中定義
data:{
dis:true}
acertain:function(){
...代碼
this.setData({
dis:false//設為方法為無
})
}
//在觸發打開對話框的方法中重新啟用對話框確定按鈕方法
this.setData({
dis:false//啟用確定方法
})
后續補充 方法2:
定義全局變量isClick
var isClick=true;
if (isClick) {
isClick = false;
setTimeout(function () {
isClick = true;
}, 1000);//一秒內不能重復點擊
}else{
return;
}
另一種方法在 https://www.cnblogs.com/shanchui/articles/12963977.html
