get started with React Native-001
发布时间:2020-12-15 04:52:45 所属栏目:百科 来源:网络整理
导读:http://facebook.github.io/react-native/docs/getting-started.html#content Requirements OS X - This repo only contains the iOS implementation right now,and Xcode only runs on Mac. New to Xcode?Download itfrom the Mac App Store. Homebrewis th
http://facebook.github.io/react-native/docs/getting-started.html#content Requirements
Quick start
In the newly created folder
Congratulations! You've just successfully run and modified your first React Native app. 创建项目
初次打开的项目结构
#import "AppDelegate.h" #import "RCTRootView.h" @implementation AppDelegate - (BOOL)application:(UIApplication *)application didFinishLaunchingWithOptions:(NSDictionary *)launchOptions { NSURL *jsCodeLocation; // Loading JavaScript code - uncomment the one you want. // OPTION 1 // Load from development server. Start the server from the repository root: // // $ npm start // // To run on device,change `localhost` to the IP address of your computer,and make sure your computer and // iOS device are on the same Wi-Fi network. jsCodeLocation = [NSURL URLWithString:@"http://localhost:8081/index.ios.bundle"]; // OPTION 2 // Load from pre-bundled file on disk. To re-generate the static bundle,run // // $ curl http://localhost:8081/index.ios.bundle -o main.jsbundle // // and uncomment the next following line // jsCodeLocation = [[NSBundle mainBundle] URLForResource:@"main" withExtension:@"jsbundle"]; RCTRootView *rootView = [[RCTRootView alloc] initWithBundleURL:jsCodeLocation moduleName:@"AwesomeProject" launchOptions:launchOptions]; self.window = [[UIWindow alloc] initWithFrame:[UIScreen mainScreen].bounds]; UIViewController *rootViewController = [[UIViewController alloc] init]; rootViewController.view = rootView; self.window.rootViewController = rootViewController; [self.window makeKeyAndVisible]; return YES; }
(编辑:李大同) 【声明】本站内容均来自网络,其相关言论仅代表作者个人观点,不代表本站立场。若无意侵犯到您的权利,请及时与联系站长删除相关内容! |