React-Native我们需要写一套代码同时运行在IOS和安卓上面,为了做到这一点我们把index.ios.js和index.android.js中的代码删除掉,然后新建一个
App.js文件,内容如下:
importReact, {Component}from'react';
import{
StyleSheet,
Text,
View
}from'react-native';
classAppextendsComponent{
render() {
return(
Welcome to React Native!
);
}
}
conststyles=StyleSheet.create({
welcome: {
fontSize:20,
textAlign:'center',
margin:10,
},
});
export defaultApp
第二步,修改index.ios.js和index.android.js
修改如下
importReact, {Component}from'react';
import{
StyleSheet,
AppRegistry,
View,
}from'react-native';
importAppfrom'./App'
AppRegistry.registerComponent('ac', () => App);
运行效果如下:无图,