【问题标题】:textinput value on scrollview滚动视图上的文本输入值
【发布时间】:2023-04-08 14:39:01
【问题描述】:

我想改变 textInput 的值,但它改变了 textinput 的所有值,我知道是因为状态,但是处理这个 textInput 的正确方法或我使用的是来自 react-native-numeric-input 的 numericInput,谢谢帮助。

<ScrollView>
  {this.state.display.map((info)=>{
    return 
    <View style={{paddingBottom:5,alignSelf:'center'}} key={info.id}>
      <View style={{ ... }}>
        <View style={{flexDirection:'row'}}>
          ...
          <View style={{justifyContent:'center',marginLeft:'auto',marginRight:10}}>
            <NumericInput 
              totalWidth={70} 
              totalHeight={30} 
              iconSize={10}
              initValue={this.state.v6}
              value={this.state.v6}
              onChange={(v6) => this.setState({ v6 })} 
              rounded 
              textColor='#59656F' 
              iconStyle={{ color: 'white' }} 
              rightButtonBackgroundColor='#AC9FBB' 
              leftButtonBackgroundColor='#DDBDD5' 
            />
          </View>
        </View>
      </View>
    </View> 
  })}
</ScrollView>

这是我的州代码

state={
  v6:0
}

【问题讨论】:

    标签: react-native expo react-native-textinput


    【解决方案1】:

    尝试将 onChange 更改为:

    onChange={(value) => this.setState({ v6: value })} 
    

    【讨论】:

      猜你喜欢
      • 2013-08-06
      • 1970-01-01
      • 1970-01-01
      • 2017-02-06
      • 1970-01-01
      • 1970-01-01
      • 2019-02-08
      • 2013-06-20
      • 2014-04-20
      相关资源
      最近更新 更多