问题
最近在用Electron中使用webview时发现当激活touch模式后,如果鼠标先点击了webview以外的区域使得焦点不在webview中,再回到webview时第一次点击无效。
在Electron的issue中搜了一下发现这竟然又是一个从第一个版本到现在一直存在的Bug。
规避方案
既然Electron没有提供可以解决这个问题的方法,那就只能想办法规避这种情况了。
在webview的页面中增加对touchstart、touchmove、touchend的监听后发现:
window.addEventListener('touchend', (e) => {
console.log('touchend', e)})
window.addEventListener('touchmove', (e)=>{
console.log('touchmove', e)})
window.