【问题标题】:React Native TextInput not scroll in ScrollViewReact Native TextInput 不在 ScrollView 中滚动
【发布时间】:2021-10-12 07:56:21
【问题描述】:

我这样写代码:

<View style={{flex:1}}>
    <ScrollView style={{flex:1, backgroundColor='#ffffff'}}>
        <TextInput style={styles.inputText} 
                   value={this.state.mail}
                   placeholder="Email"
                   onChangeText={(text)=>this.setState.(mail:text)}/>
        <TextInput style={styles.inputText} 
                   value={this.state.fName}
                   placeholder="First name"
                   onChangeText={(text)=>this.setState.(fName:text)}/>
        <TextInput style={styles.inputText} 
                   value={this.state.sName}
                   placeholder="Second name"
                   onChangeText={(text)=>this.setState.(sName:text)}/>
    </ScrollView>
</View>

但是当我在 TextInput 中拖动 start 时不会滚动! 我像这样拖动图片: enter image description here 但不能滚动...

【问题讨论】:

  • 尝试再添加 3 个 TextInput
  • 从滚动视图中移除 flex:1。

标签: javascript reactjs react-native scrollview react-native-textinput


【解决方案1】:

问题解决了。我只是将这个道具添加到 TextInput 组件中:

multiline={true}
numberOfLines={1}

【讨论】:

    猜你喜欢
    • 2018-09-04
    • 2019-07-16
    • 2018-04-09
    • 1970-01-01
    • 1970-01-01
    • 2021-08-11
    • 1970-01-01
    • 2019-07-18
    • 2016-01-06
    相关资源
    最近更新 更多