Warning: Failed prop type: Invalid prop value of type number supplied to Textinput, expected string

朴灿烈づ我的快乐病毒、 2022-02-27 07:49 265阅读 0赞

react-native 使用TextInput标签时会遇到这个警告:

Warning: Failed prop type: Invalid prop value of type number supplied to Textinput, expected string in Textinput (at Appointmentnumber is: 112) in Appointmentnumber(created by Context. Consumen)in withnavigation(Appointmentnumber)(created bySceneview

20190327101140906.png

在道具中你传递的是数值,你必须以字符串的形式传递它,所以这样改进一下代码:

  1. <TextInput
  2. style={styles.textinput}
  3. placeholder="站厅预约人数"
  4. placeholderTextColor = "#cccccc"
  5. keyboardType = "numeric"
  6. value={`${this.state.num}`} //这里改进一下就OK
  7. onChangeText={(num)=> {this.setState({num})}}
  8. />

发表评论

表情:
评论列表 (有 0 条评论,265人围观)

还没有评论,来说两句吧...

相关阅读