We read every piece of feedback, and take your input very seriously.
To see all available qualifiers, see our documentation.
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
<View style={styles.container}> <DatePickerIOS date={this.state.initDate} onDateChange={this.setDate} /> </View> const styles = StyleSheet.create({ container: { flex: 1, justifyContent: "center", alignItems: "center", backgroundColor: "#F5FCFF" }, welcome: { fontSize: 20, textAlign: "center", margin: 10 }, instructions: { textAlign: "center", color: "#333333", marginBottom: 5 } })
由于没有给DatePickerIOS组件指定宽度,而父组件中 alignItems:center,故而导致DatePickerIOS组件的宽度为0,所以无法展示
alignItems:center
第一种: 给DatePickerIOS指定宽度如 <DatePickerIOS style={{ width: Dimensions.get("window").width }} date={this.state.initDate} onDateChange={this.setDate} />
<DatePickerIOS style={{ width: Dimensions.get("window").width }} date={this.state.initDate} onDateChange={this.setDate} />
第二种:去掉alignItems:center,因为 alignItems的默认值是stretch (如果项目未设置高度或设为auto,将占满整个容器的高度。)
alignItems
stretch (如果项目未设置高度或设为auto,将占满整个容器的高度。)
The text was updated successfully, but these errors were encountered:
No branches or pull requests
代码
原因分析
由于没有给DatePickerIOS组件指定宽度,而父组件中
alignItems:center
,故而导致DatePickerIOS组件的宽度为0,所以无法展示解决办法
第一种: 给DatePickerIOS指定宽度如
<DatePickerIOS style={{ width: Dimensions.get("window").width }} date={this.state.initDate} onDateChange={this.setDate} />
第二种:去掉
alignItems:center
,因为alignItems
的默认值是stretch (如果项目未设置高度或设为auto,将占满整个容器的高度。)
The text was updated successfully, but these errors were encountered: