【发布时间】:2018-08-15 10:54:50
【问题描述】:
我似乎无法让键盘在我的 React-Native Expo 应用程序中向上推送内容。我正在通过从我的开发机器发布它来从 expo App 测试它。
尽我所能,当键盘成为焦点时,似乎没有任何东西可以将视图向上推,是否有特定的组件顺序,或者我缺少某些属性;我已经包含了我认为相关的版本、渲染块和样式块。
我正在使用以下版本(最新);
"expo": "^29.0.0",
"react": "16.3.1",
"react-native": "https://github.com/expo/react-native/archive/sdk-29.0.0.tar.gz",
对于登录页面,渲染代码如下所示;
render() {
return (
<SafeAreaView style={styles.flexContainer}>
<KeyboardAvoidingView
style={styles.flexContainer}
behavior="padding"
>
<Image style={styles.image} source={require('../../assets/images/backgroundWelcome.png')} role="presentation" />
<View style={styles.container}>
<View style={[styles.row, styles.border]}>
<TextInput
placeholder='Email'
style={styles.input}
onChangeText={(input) => this.setState({email: input})}
value={this.state.email}
/>
</View>
<View style={[styles.row, styles.border]}>
<TextInput
placeholder='Password'
style={styles.input}
secureTextEntry={true}
onChangeText={(input) => this.setState({password: input})}
value={this.state.password}
/>
</View>
<View style={styles.row}>
<StyledButton callback={this.handleLogin} title='Log In'/>
</View>
</View>
</KeyboardAvoidingView>
</SafeAreaView>
)
}
这些是相关的样式;
root: {
flex: 1,
alignItems: 'center',
backgroundColor: '#fff',
},
flexContainer: {
flex: 1,
},
container: {
paddingHorizontal: 40,
paddingBottom: 22,
alignItems: 'center',
flex: -1
},
row: {
flexDirection: 'row',
marginVertical: 10,
},
【问题讨论】:
-
你解决过这个问题吗?我也遇到了这样的问题。 stackoverflow.com/questions/52112707/…
-
我希望下面的内容可以提供一些见解,如果有,请点赞。
标签: javascript reactjs react-native expo