我最近安装了带有react Native和Node的AS。当我启动模拟器时,它将构建页面。但是在模拟器本身中,它仅显示空白的React页面。在中心是正方形,但正方形也是空白。 我忘了安装东西吗?
另一个简短的问题: 当我想用React Native创建应用程序时,我需要获得最终版的Intellij吗?所有已创建的.js页面均为红色,并且AS消息显示.js只能与Ultimate Edition一起使用。
import React from 'react';
import { Platform, StyleSheet, Text, View } from 'react-native';
export default class App extends React.Component {
constructor () {
super();
this.state = {
todoInput: "",
todos: [
{id: 0, title: "Take out the trahs", done:false},
{id: 1, title: "Cook dinner", done: false}
]
}
}
render() {
const statusbar = (Platform.OS == "android") ? <View style= {styles.statusbar}></View> : <View></View>;
return (
<View style={styles.container}>
{statusbar}
</View>
);
}
}
const styles = StyleSheet.create({
container: {
flex: 1,
backgroundColor: '#000',
},
statusbar: {
backgroundColor: "#FFCE00",
height:20
}
});
答案 0 :(得分:1)
您的代码不是空白页。您的视图位于状态栏区域。状态栏区域的颜色已更改。视图的起点从设备的顶部开始,因为您尚未找到flex值或子视图。
如果像我的回答一样将justifyContent
的值设置到中心,则会看到您设置的视图。
container: {
flex: 1,
backgroundColor: '#000',
justifyContent:"center"
},