Native App 和 Web App 折中的方案,保留了 Native App 和 Web App 的优点。但是最受吐槽的还是性能差。页面渲染效率低,在Webview中绘制界面,实现动画,资源消耗都比较大。
React-Native
What we really want is the _user experience_ of the native mobile platforms, combined with the _developer experience_ we have when building with React on the web.
React-Native 基于目前React来开发IOS原生应用,Android版本将在年底推出。
为什么需要React-Native
目前主流的应用大体分成三类:Native App, Web App, Hybrid App.
Native App
优点
Web App
优点
Hybrid App
Native App 和 Web App 折中的方案,保留了 Native App 和 Web App 的优点。但是最受吐槽的还是性能差。页面渲染效率低,在Webview中绘制界面,实现动画,资源消耗都比较大。
React-Native
What we really want is the _user experience_ of the native mobile platforms, combined with the _developer experience_ we have when building with React on the web.
这是 React-Native 设计的初衷: _既保留流畅的用户体验,有保留React的开发效率_。
React-Native 做了什么
对应前端的开发模式的变化:
如何开始
jsCodeLocation
的定义是否正确。cmd + R 刷新模拟器即可看到效果,就是这么简单。
进阶玩法,自定义UI组件
如下图,实现课程管理的效果:
在入口文件中,require上面的文件,然后在render方法中直接调用改组件即可。