【发布时间】:2019-07-22 10:50:54
【问题描述】:
我有一个在framework7 中打开模式的按钮,但是如果双击,模式会打开两次,我试图在没有运气的情况下不允许双击该按钮。
$(Button, {
fill: true,
raised: true,
noFastClick: true,
onClick: this.handle_click
})
const clickTimes: any[] = []
handle_click = (button) => {
const clickTime = new Date().getTime()
clickTimes.push(clickTime)
if (clickTimes.length > 1) {
console.log("double click detected")
button.disabled = true
clickTimes.length = 0
return
}
}
任何帮助将不胜感激。
【问题讨论】:
-
检查模态框是否已经在事件处理程序之外渲染。或者在单击时删除事件处理程序并在关闭模式时读取它。或者只是使用 debounce 功能,就像您尝试自己编写一样。 davidwalsh.name/javascript-debounce-function
标签: javascript reactjs ecmascript-6 ecmascript-5 html-framework-7