一.初始化一个ReactNative项目
- 在指定目录运行命令:react-native init Vince(项目名称) //其过程就是在使用CLI工具构建项目,
- 命令行代码
- 创建完的项目目录结构为:
F:\React>react-native init Vince
This will walk you through creating a new React Native project in F:\React\Vince
Installing react-native package from npm...
Setting up new React Native app in F:\React\Vince
react@15.0.2 node_modules\react
├── object-assign@4.1.0
├── loose-envify@1.2.0 (js-tokens@1.0.3)
└── fbjs@0.8.2 (ua-parser-js@0.7.10, promise@7.1.1, isomorphic-fetch@2.2.1, core-js@1.2.6)
To run your app on iOS:
cd F:\React\Vince
react-native run-ios
- or -
Open F:\React\Vince\ios\Vince.xcodeproj in Xcode
Hit the Run button
To run your app on Android:
Have an Android emulator running (quickest way to get started), or a device connected
cd F:\React\Vince
react-native run-android
- 在模拟器端运行
- 使用AndroidStudio运行创建模拟器,并运行
- 项目目录下运行命令react-native run-android
- 模拟器中出现如下界面,则代表构建项目成功