reactjs - react native ScrollView 不会从文本输入内部滚动

标签 reactjs react-native

我在 ScrollView 中添加了多文本输入。问题是当我想从文本输入内部向下滚动时,我将手指放在文本输入内部并向下滚动,但它没有向下滚动页面,有没有办法解决这个问题? 这是示例代码:

export default class ScrollViewWithTextInput extends React.Component {
render() {
    <ScrollView>
        <TextInput
            style={styles.input}
            placeholder={'توضیحات'}
            underlineColorAndroid='transparent'
        />
        <TextInput
            style={styles.input}
            placeholder={'توضیحات'}
            underlineColorAndroid='transparent'
        /><TextInput
            style={styles.input}
            placeholder={'توضیحات'}
            underlineColorAndroid='transparent'
        /><TextInput
            style={styles.input}
            placeholder={'توضیحات'}
            underlineColorAndroid='transparent'
        />
        <TextInput
            style={styles.input}
            placeholder={'توضیحات'}
            underlineColorAndroid='transparent'
        />
        <TextInput
            style={styles.input}
            placeholder={'توضیحات'}
            underlineColorAndroid='transparent'
        /><TextInput
            style={styles.input}
            placeholder={'توضیحات'}
            underlineColorAndroid='transparent'
        /><TextInput
            style={styles.input}
            placeholder={'توضیحات'}
            underlineColorAndroid='transparent'
        />
    </ScrollView>
}}
const styles = StyleSheet.create({
Container: {
    flex: 1,
    justifyContent: 'center',
    alignItems: 'center',
    marginTop: 8
},
input: {
    width: 350,
    height: 100,
    margin: 5,
    borderColor: 'black',
    borderWidth: 2,
    textAlign: 'right'
}})

最佳答案

出于某种原因,将 multiline={true} 设置为 TextInput 对我有用。

不太清楚为什么。更奇怪的是,如果您还有 keyboardType='numeric',它将无法工作。

关于reactjs - react native ScrollView 不会从文本输入内部滚动,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/46564649/

相关文章:

reactjs - 有什么方法可以在导入 native react 之前检查组件是否存在

react-native - react native 中的三元运算符

javascript - ImageBackground 包装器内的 React Native Text 未显示(带图像)

javascript - Jest css-modules SyntaxError : Unexpected token

reactjs - ThemedStyledProps 类型上不存在属性 'name'

javascript - 从 react 中的组件中确定无状态组件名称

javascript - 使用 enzyme 测试 React Native FlatList

javascript - 单击其他组件中的某个按钮更改语义 UI 选项卡

javascript - ReactJs中可以动态获取父组件类名吗

javascript - 在 react-native 中自动化应用程序图标/启动画面链接(可能使用 rnpm)?