React Native事件不会触发

时间:2019-06-18 09:20:28

标签: reactjs react-native events pointer-events

这是我的this.myService.requestFromServer(...).subscribe(resp => { console.log(resp); this.data = resp.data; // do the rest }, error => { console.log(error); }, () => { // on complete console.log(this.data); }); 方法的主体。为什么这些事件都不触发?

render()

这是在我的return ( <View style={{flex:1}} onPointerDown={e => this._events.emit("pointerdown", e)} onPointerUp ={e => this._events.emit("pointerup", e)} onPointerMove={e => this._events.emit("pointermove", e)} > ... </View> ); 文件中。我尝试用App.js替换事件正文,但终端或Web调试页面上没有任何内容。

1 个答案:

答案 0 :(得分:1)

这些事件未触发是因为:onPointerUponPointerDownonPointerMove不是react-native的View道具的一部分。

如果要处理触摸,请检查以下内容:

https://facebook.github.io/react-native/docs/handling-touches

https://facebook.github.io/react-native/docs/view.html#synthetic-touch-events