react-native
跨平台一直是开发者的梦想,而且移动应用的跨平台解决方案目前也很多,在Facebook 的参与和力推下,让这个解决方案带上了光环。第一个用 React Native 开发的 App 已经在 Google Play 上架 Facebook 广告管理工具,听说 Android 的 SDK 也马上会到来,国内天猫团队以及在去年10月首次实现,携程也基于React Native推出mouse, 相信不久后会有更多的框架封装的出现。但是,在2018年6月20号,Airbnb 技术团队在 Medium 上宣布,Airbnb 放弃使用 React Native,将回归到使用基于原生技术的自有框架开发 App。
IDE | React Native中文网 | github | 分享 50 个完整的 React Native 项目
react-native 发布/订阅事件总线EventBus 使用
关于RN组件的导出export和export default
一般我们在定义了一个组件之后,为了复用,需要将它导出以提供给其他页面使用。
组件导出的关键字是
exprot default 1 没有加default时,例如:
export class Template{} 1 当然,你可以在单个js文件里声明多个组件,例如Templates.js
export class Template{} export class AnotherTemplate{} 1 2 这样在其他文件引用时,需要使用{}符号且组件名称必修和class名称一样,像这样子:
import {Template,AnotherTemplate} from './components/Templates'; 1 而加default时,例如:
export default class Template{} 1 然后在其他文件引用,像这样子:
import Template from './components/Templates'; 1 你也可以为这个组件另起一个别名,像这样子:
import TheTemplate from './components/Templates'; 1 但是每个文件里只能有个default组件,可以包含其他非default组件:
export default class Template{} export class AnotherTemplate{} 1 2 然后引用的时候,如下:
import Template,{AnotherTemplate} from './components/Templates'; 1 总结 有default和没有default的区别在于:有default在引用时可以自定义名称,而没有default时需要使用{}括起来且名称必修和class名称一致 每个文件里只能有一个default组件,但可以有多个非default组件
资料
http://blog.csdn.net/yuanguozhengjust/article/details/50468561 https://nuclide.io/docs/quick-start/getting-started/ http://bbs.reactnative.cn/category/5/%E5%88%86%E4%BA%AB#content http://lib.csdn.net/article/reactnative/40082 https://blog.csdn.net/sinat_17775997/article/details/70207683 https://www.jianshu.com/p/79cdebed6ee5 https://www.jianshu.com/p/438ff1936dd4 http://wiki.jikexueyuan.com/project/react-native/ http://segmentfault.com/a/1190000002658374 http://www.woshipm.com/pd/123646.html https://www.zhihu.com/question/31585377/answer/52576501 http://facebook.github.io/react-native/docs/getting-started.html