利用 Create React Native App 快速创建 React Native 应用

1创建React Native App简介

创建React Native App是Facebook与Expo联合开发的用于快速创建React Native应用的工具,创建React Native App可以在没有安装React Native的IDE(Nuclide,WebStorm等)时,可以将应用运行在Expo的客户端应用内,还可以加载远程的JavaScript的代码而不用进行原生代码编译操作;

Github:https://github.com/react-community/create-react-native-app

2.环境搭建

npm i -g create-react-native-app
create-react-native-app my-project --version 0.55.4
cd my-project
npm start

下面是项目安装完成后的命令:

Inside that directory, you can run several commands:

  npm start
    Starts the development server so you can open your app in the Expo
    app on your phone.

  npm run ios
    (Mac only, requires Xcode)
    Starts the development server and loads your app in an iOS simulator.

  npm run android
    (Requires Android build tools)
    Starts the development server and loads your app on a connected Android
    device or emulator.


  npm test
    Starts the test runner.

  npm run eject
    Removes this tool and copies build dependencies, configuration files
    and scripts into the app directory. If you do this, you can’t go back!

1 npm start:启动开发服务器,以便在Expo中打开您的应用程序手机上的应用程序。

2 npm run ios / Android:启动开发服务器连接iOS或Android;

3 npm test:启动测试运行器;

4 npm run eject:删除此工具并复制构建依赖项,配置文件和脚本到app目录中。如果你这样做,你就不能回去了!

3 运行React Native项目

进入项目目录输入:

npm start

出现下面:

4. 安装Expo手机客户端

Expo官网:https://expo.io/tools#client

下载并安装Expo客户端,然后使用二维码扫描上面的二维码进行访问;

猜你喜欢

转载自blog.csdn.net/niuba123456/article/details/81951689