React Click events not firing on mobile

前端 未结 2 1663
深忆病人
深忆病人 2020-12-30 04:34

I\'ve been working with react for a couple of months now, but have just run into something a little weird.

Click events aren\'t being fired at all on mobile devices:

相关标签:
2条回答
  • 2020-12-30 05:15

    I had the same issue when using Chrome browser, but when I used Firefox the onClick handler was working fine and thus the issue was in Chrome because chrome made some breaking changes for handling touches and because I was preventing default and handling it myself it wasn't working. Try running in Firefox it will work.

    0 讨论(0)
  • 2020-12-30 05:21

    There are a few issues in React's Github project which might be helpful.

    • onClick on mobile not fired
    • MobileSafariClickEventPlugin requires touch events to be initialized

    Looks like, you need to add a CSS cursor:'pointer' so that mobile phones (iOS devices specifically) fire native click event on the element.

    0 讨论(0)
提交回复
热议问题