uni-app 小程式雙擊事
目前uni-app view標簽不支持雙擊事件,下面自定義雙擊事件:
// A code block
<view @click="handClick(index)"></view>
data(){
return {
lastTapTimeoutFunc:null,
lastTapDiffTime:0
}
},
methods:{
// 單擊或雙擊
handClick(index) {
let _this = this;
let curTime = new Date().getTime();
let lastTime = _this.lastTapDiffTime;
_this.lastTapDiffTime = curTime;
//兩次點擊間隔小于300ms, 認為是雙擊
let diff = curTime - lastTime;
if (diff < 300) {
console.log("雙擊")
//_this.handleVideo('screen',index)自定義事件
clearTimeout(_this.lastTapTimeoutFunc); // 成功觸發雙擊事件時,取消單擊事件的執行
} else {
// 單擊事件延時300毫秒執行
_this.lastTapTimeoutFunc = setTimeout(function() {
console.log("單擊")
//_this.handleVideo('playOrStop',index)自定義事件
}, 300);
}
}
}
轉載請註明出處,本文鏈接:https://www.uj5u.com/qukuanlian/254796.html
標籤:區塊鏈
下一篇:Go語言學習心路
