onClick 似乎不太适用于移动设备,但它在桌面浏览器上运行良好。在移动设备上执行此操作的最佳方法是什么 - 知道何时按下元素?
这是我在返回声明中使用它的方式:
...
return (
<div>
<div
className={"bus-route-number " + this.props.data.busNumber}
onClick={this.toggleShowDestination}
>
<h1>{this.props.data.busNumber}</h1>
<h4>{this.props.data.fullRoute}</h4>
</div>
{destinations}
</div>
)
...
最佳答案
您将不得不使用触摸事件。为了启用触摸事件,您必须在渲染任何组件之前运行以下命令。
React.initializeTouchEvents(true)
关于reactjs - onClick 在手机上用什么?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/32363420/