【发布时间】:2018-05-20 14:02:27
【问题描述】:
始终选中:
- Can Meteor call a method on the server twice if the client gets disconnected?
- OnClick Event gets fired twice
- JavaScript multiple keys pressed at once
- Detect multiple keys on single keypress event in jQuery
- https://therelentlessfrontend.com/2012/11/13/detect-multiple-key-press-in-javascript-for-your-website/
- Prevent JavaScript keydown event from being handled multiple times while held down
- Can Meteor call a method on the server twice if the client gets disconnected?
- https://groups.google.com/forum/#!msg/meteor-talk/j1YF7JO5Rdo/cYHR5kbhC8UJ
你好,
我在我的数据库中发现 Meteor 方法已通过单击或按键执行了多次。
我没有设法触发错误。
这是我的代码:
class Answering extends Component {
...
validAnswer() {
...
validAnswer.call({
...
});
}
...
render() {
return (
...
<div
id="Answering-button-next"
role="button"
onClick={() => { this.validAnswer(); }}
onKeyPress={(e) => { if (e.key === 'Enter') this.validAnswer(); }}
tabIndex="0"
>OK
</div>
如何修复此错误?
谢谢
【问题讨论】:
-
只是偶尔发生吗?如果是这样,很可能是重新连接后重新运行或失败后重试。
-
@MasterAM : 关注数据库,是的,非常非常罕见。
-
日志呢?是否有关于服务器重启时错误或方法重新运行的报告?
标签: javascript reactjs meteor onclick keypress