2022-02-07——模拟双击事件(基于uni-app)

export default {
data() {
return {
touchStartTime: 0
}
},

methods: {
    doubleClick() {
        if (this.touchStartTime === 0) {
            this.touchStartTime = new Date().getTime()
            setTimeout(() => {
                this.touchStartTime = 0
            }, 300)
        } else {
            if (new Date().getTime() - this.touchStartTime <= 300) {
                wx.showModal({
                    showCancel: false,
                    content: '你双击了'
                })
            }
            this.touchStartTime = 0
        }
    }
}

}

你可能感兴趣的:(2022-02-07——模拟双击事件(基于uni-app))