【React Native初步学习】

@React Native初步学习

一、认识React Native

React Native是一个跨平台跨端的混合式开发前端框架,基于React基础进行开发;当时最新版是0.73,下面即将介绍npx命令行工具。

npx

npx是npm 5.2以上版本自带的一个命令行工具。它是一个很小的模块,具有执行本地安装的包中的二进制文件(如:JavaScript文件)的功能,是一个快速执行Node.js包库中的命令的工具。

在使用旧版的npm时,我们通常需要全局安装一些包和工具才能使其在命令行中生效,既浪费了时间又增加了安装的负担。然而,npx不需要全局安装,它可以自动查找你本地的npm包,安全快捷地执行来自npm库中的命令。

总之,npx是一个非常方便的npm命令,可以让我们在没有全局安装包、没有版本冲突和节省命令行时间的情况下,运行npm包的任何命令。同时,我们还可以使用npx创建自己的命令,方便自己和他人使用。

在学习新的开发技术的时候,总少不了搭建开发环境,环境搭建可参考官网或者网上技术文章,,推荐直接参照官方文档,毕竟是最新的也比较详细。环境搭建好后就是进入正题开始创建项目了

二、正式使用

在运行前确保已连接设备(真机手机或Pad)或者开启模拟器

1、新建react-native项目

使用命令
npx react-native init RNDemo

注:npx react-native init 项目名称

2、启动地铁

使用命令
npx react-native start

启动后会提示以下信息
info Dev server ready

i - run on iOS
a - run on Android
d - open Dev Menu
r - reload app

键盘输入 i 就是在苹果设备上打开,输入 a 就是在安卓设备上打开

3、安装基座并运行打开

info Opening app on Android…
info A dev server is already running for this project on port 8081.
info Installing the app…

Starting a Gradle Daemon, 1 busy Daemon could not be reused, use --status for details
。。。。。。

Task :app:installDebug
Installing APK ‘app-debug.apk’ on ‘Nexus_5_API_30-Test(AVD) - 11’ for :app:debug
Installed on 1 device.

BUILD SUCCESSFUL in 48s
43 actionable tasks: 43 executed
info Connecting to the development server…
8081
info Starting the app on “emulator-5554”…
Starting: Intent { act=android.intent.action.MAIN cat=[android.intent.category.LAUNCHER] cmp=com.rndemo1/.MainActivity }
BUNDLE ./index.js

注:上面是运行到模拟器上提示的信息,看到BUILD SUCCESSFUL基本上是正常运行了

特此说明:创建一个特定版本的React Native项目,你可以使用以下命令:
npx react-native init MyApp --version X.XX.X
其中,MyApp是你的项目名称,X.XX.X是你想要使用的React Native版本号。

  • 34
    点赞
  • 33
    收藏
    觉得还不错? 一键收藏
  • 0
    评论
React Native By Example by Richard Kho English | 24 Apr. 2017 | ASIN: B01M31KB4Q | 414 Pages | AZW3 | 4.46 MB Key Features Work on native APIs and UI Elements using React Native Get the best of both worlds: the power of native approach and the fluidity of JavaScript Create increasingly complex real-world applications and dive deeper into React Native Book Description React Native's ability to build performant mobile applications with JavaScript has resulted in its popularity amongst developers. Developers now have the luxury to create incredible mobile experiences that look and feel native to their platforms with the comfort of a well-known language and the popular React.js library. This book will show you how to build your own native mobile applications for the iOS and Android platforms while leveraging the finesse and simplicity of JavaScript and React. Throughout the book you will build three projects, each of increasing complexity. You will also link up with the third-party Facebook SDK, convert an app to support the Redux architecture, and learn the process involved in making your apps available for sale on the iOS App Store and Google Play. At the end of this book, you will have learned and implemented a wide breadth of core APIs and components found in the React Native framework that are necessary in creating great mobile experiences. What you will learn How to create mobile-performant iOS and Android apps using JavaScript and React The potential of each API and component, putting them into practice throughout the course of three projects The process of integrating the Facebook SDK to build an app that connects to third-party data Every step taken to implement Redux, a popular state management library, in your mobile apps The requirements for building and deploying your apps to market, with detailed instructions on how to release and beta test apps on both the Apple App Store and Google Play About the Author Richard Kho is a software engineer livin

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值