事件目标值返回未定义

时间:2020-03-29 02:51:14

标签: reactjs react-native

从React Native中的TextInput打印事件的值时,event.target是一个整数,而event.target.value是未定义的。

我正在使用的代码如下:

<TextInput
  onChange={(e) => console.log(e.target.value)}
  style={styles.input}
  type="text"
  name={serviceId}
  data-id={idx}
  id={serviceId}
  value={props.services[idx].name}
  className="name"
/>

1 个答案:

答案 0 :(得分:1)

要获取要使用的值

onChangeText={(value) => console.log(value)}

Check the docs for more info

相关问题