react-native - 滚动视图上的文本输入值
问题描述
我想改变 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
}
解决方案
尝试将 onChange 更改为:
onChange={(value) => this.setState({ v6: value })}
推荐阅读
- python - 将字符串减去第一个和最后一个字符返回到递归函数
- javascript - 使用 iFrame 放置 Javascript API 谷歌地图
- python - 在 softmax 上使用 sigmoid 有什么区别?(自动编码器,keras)
- python - 当python Requests post数据是字符串类型时,默认编码是什么?
- php - 如何在同一行中获得相同值和不同值的总和?
- go - 变量初始化是否有错误
- ios - 当应用程序被带到前台时,是否需要重新创建 MTLBuffer、MTLTexture 或其他金属资源?
- c++ - “uintmax_t”:不是“全局命名空间”的成员
- angular - Angular 7 for 循环范围,从 x 到 x+y
- video-streaming - 如何使用媒体源扩展 (MSE) 低延迟模式