小编Tha*_*ham的帖子

通过使用textInput React Native在状态下更新数组对象中的元素

我要在这里做的是使用textInput更新数组对象“可用”,下面是我的代码。我不知道为什么它会在_update函数行中不断给我令牌错误。请帮忙。谢谢!

export class Inventory extends Component {
state = {
    available: [
        {id: 0, name: 'Xb', value:5},
        {id: 1, name: 'Ad', value:19},
        {id: 2, name: 'Sc', value:1},
        {id: 3, name: 'AV', value:3},
        {id: 4, name: 'Ba', value:8},
        {id: 5, name: 'Ch', value:2},
        {id: 6, name: 'Pr', value:9},
        {id: 7, name: 'Mi', value:10},
        {id: 8, name: 'Se', value:1},
    ],
}

    _update = (text,index) => this.setState({available[index].value: text});

render(){
 index = 0;
  return(
    <View style={styles.container}> 
      <TextInput style={styles.input}
      keyboardType = 'number-pad'
      returnKeyType = 'go' …
Run Code Online (Sandbox Code Playgroud)

textinput react-native

4
推荐指数
1
解决办法
5734
查看次数

标签 统计

react-native ×1

textinput ×1