React 事件不会在移动设备上触发,但在桌面上运行良好。我试过 onClick、onTouchStart、onTouchEnd、onMouseUp、OnMouseDown

心电图

当我尝试单击按钮事件本身不会在移动设备中触发。我在桌面上工作正常。

我看到了一些帖子并尝试了 cursor ,z-Index 属性,但没有任何效果。

<div>
     <button  style ={{ cursor: 'pointer', zIndex : 1000 }} 
               onClick={ () => { console.log("ABC")} } >Button</button>
</div>

onclick 按钮应该打印“ABC”

六月 L。

添加postion: 'relative'. 默认值为静态,将其从静态添加相对位置更改。

<div>
   <button style={{ cursor: 'pointer', zIndex: 1000, position: 'relative' }}
     onClick={() => { console.log("ABC") }} >Button</button>
</div>

演示

本文收集自互联网,转载请注明来源。

如有侵权,请联系 [email protected] 删除。

编辑于
0

我来说两句

0 条评论
登录 后参与评论

相关文章