React Native-13.React Native 常用API及实践 AppRegistry
来源:互联网 发布:java md5加解密 编辑:程序博客网 时间:2024/05/18 02:21
AppRegistry简介
AppRegistry是RN应用的入口函数。
程序入口组件使用AppRegistry.registerComponent
来注册。当注册完应用程序组件后,Native系统(OC)就会加载jsbundle文件并触发AppRegistry.runApplication
运行应用。AppRegistry有以下方法:
- registerConfig(config:Array): 静态方法,注册配置。
- registerComponent(appKey:string,getComponentFunc: ComponentProvider): 注册入口组件。
- registerRunnable(appKey:string , func :Function): 注册函数监听。
- getAppKeys(): 获取registerRunnable注册的监听键。
- runApplication(appKey:string,appParameter:any): 运行App
实例
在前边的文章中,我们都使用了AppRegistry.registerComponent
如:
AppRegistry.registerComponent('wxsPrj', () => wxsPrj);
我们在XCode启动RN程序的时候会在log栏中看到这样的输出:
2016-02-24 12:05:36.838 [trace][tid:com.facebook.React.JavaScript] Running application "wxsPrj" with appParams: {"rootTag":1,"initialProps":{}}. __DEV__ === true, development-level warning are ON, performance optimizations are OFF
这个日志信息是由runApplication
打印出来的。
我们可以用alert(AppRegistry.runApplication);
在程序中以提示框的形式看runApplication
函数的定义。
我们还可以使用registerRunnable
注册一些AppKey,实例:
AppRegistry.registerRunnable('wxs',function(){ console.log('was');})alert(AppRegistry.getAppKeys());
0 0
- React Native-13.React Native 常用API及实践 AppRegistry
- React Native 的常用组件和API-AppRegistry
- React Native-14.React Native 常用API及实践 AsyncStorage
- React Native-15.React Native 常用API及实践 AlertIOS AlertSheetIOS
- React Native-16.React Native 常用API及实践 PixelRatio
- React Native-17.React Native 常用API及实践 AppStateIOS StatusBarIOS
- React Native-18.React Native 常用API及实践 NetINfo
- React Native之AppRegistry模块
- React Native——AppRegistry
- React native应用程序注册表appRegistry
- React Native 实践小结
- 携程React Native实践
- React-Native实践
- Qunar React Native 实践
- react-native + redux 实践
- 运行React Native项目报:error calling appregistry.run application
- React Native 混合编程 之常用API
- react native常用modules
- js 创建<a>标签 并触发
- 一维小波降噪的综合应用实例
- 【hud2222】Keywords Search AC自动机
- 你正在为互联网上的“免费”付出什么?
- 使用librtmp进行H264与AAC直播
- React Native-13.React Native 常用API及实践 AppRegistry
- POJ 1018(dp)
- python 双向链表
- 在Mac OS X中使用jenv管理多个Java版本
- 获取android手机的屏幕分辨率 android开发
- 设计模式之迪米特法则
- 代码优化技巧
- joda.time 处理时间--计算2个日期之间的天数
- 一个java面试题引发的思考