是fastclick使用 ReactJS 的事件系统?当通过 Cordova 在 iOS 或 Android 上运行时,它似乎并不需要花费时间。如果没有,是否有其他方法可以获得相同的结果。我的应用程序没有双击功能,因此如果可能的话,我想全面消除该延迟...
最佳答案
编辑
Facebook 决定 not add support for defining custom event types并建议您使用类似 react-tappable 的内容 所以你可以写类似 <Tappable onTap={}>
的内容.
Facebook 正在研究 TapEventPlugin
形式的解决方案,但是它won't be made available until they make some decisions .罢工>
如果您正在阅读本文,您可能正在开发一个迫不及待想知道如何发布它的项目。
此存储库适合您:https://github.com/zilverline/react-tap-event-plugin
当Facebook解决#436时和#1170 ,这个仓库将会消失。
此解决方案适用于 React 0.14.x 和 15.x。
npm i -S react-tap-event-plugin
使用示例:
var React = require("react");
var ReactDOM = require("react-dom");
injectTapEventPlugin = require("react-tap-event-plugin");
injectTapEventPlugin();
var Main = React.createClass({
render: function() {
return (
<a
href="#"
onTouchTap={this.handleTouchTap}
onClick={this.handleClick}>
Tap Me
</a>
);
},
handleClick: function(e) {
console.log("click", e);
},
handleTouchTap: function(e) {
console.log("touchTap", e);
}
});
ReactDOM.render(<Main />, document.getElementById("container"));
请注意,对于注入(inject)器,您可能只需要使用 onTouchTap
(不再是onClick
)。
关于cordova - 我可以快速单击在 Cordova 中运行的 ReactJS,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/24335821/