React Native:将2个参数传递给onPress事件

时间:2016-12-21 10:59:19

标签: javascript events react-native event-handling

我需要将两个参数传递给我的处理函数,但是我无法找到合适的sintax,有人可以帮助我吗?

MyHandler = (e) => {
  var Var_1 = e;
  var Var_2 = second_parameter;
}

render() {
  return (
     <Button onPress={(e) => this.MyHandler(e)} title="1">
  );
}

1 个答案:

答案 0 :(得分:1)

你可以这样做:

MyHandler = (e, second_parameter) => {
  var Var_1 = e;
  var Var_2 = second_parameter;
}

render() {
  return (
     <Button onPress={(e) => this.MyHandler(e, your_second_parameter)} title="1">
  );
}