reactnative中沒有雙擊事件,只能通過setTimeout實現
<!DOCTYPE html>
<html>
<head>
<meta charset="utf-8">
<title></title>
</head>
<body>
<button id='btn'>click me</button>
</body>
<script>
var id=document.getElementById('btn');
var lastclick;
var timer;
id.onclick = ()=>{
const clickTime = new Date().getTime();
if(lastclick && (clickTime-lastclick<300)){
//第二次及以上點擊
clearTimeout(timer);
console.log('dblclick');
}else{
//第一次點擊
timer = setTimeout(()=>{
console.log('click');
},300);
}
lastclick = clickTime;
}
</script>
</html>
