2016-04-15 38 views
9

所以有這麼大的公告,你現在可以write Windows apps using React Native如何開始使用React Native編寫UWP應用程序?

公告鏈接到一個Github page這反過來又導致了一些描述上how to install React Windows

花幾個小時安裝Visual Studio和依賴性,SDK和諸如此類的東西后,我有建於視覺這個「ReactNative」解決方案工作室,但我仍然無法弄清楚如何開始編寫簡單的Hello World程序。

所有文檔都指出如何在Visual Studio代碼中編寫Android或iOS程序,但沒有關於如何編寫UWP程序的說明。

有誰知道從哪裏開始?什麼是Visual Studio等效的「react-native init」?

回答

4

您已經運行react-native init AwesomeProject後...

cd AwesomeProject 
npm i --save-dev rnpm-plugin-windows 
react-native windows 

這將生成可視化Studio解決方案爲您的項目和index.windows.js入口點。 Visual Studio Code是一個編輯React Native JavaScript的好工具。

要運行您的應用程序,只需運行react-native run-windows

0

目前還沒有針對React Native爲UWP應用程序發佈的開箱即用解決方案。目前唯一支持UWP的應用程序是F8App,有關它們如何移植它的blog post

0

你幾乎在那裏,答案是你在命令行執行「react-native init」 - 你不通過Visual Studio來完成。 請參閱https://github.com/ReactWindows/react-native-windows#getting-started

Visual Studio項目創建一個UWP項目,該項目知道如何加載並運行react-native js代碼。 VS代碼基本上只是一個包裝。

要開始一個新的反應,在Windows本地項目中,打開命令行廣告執行以下操作:

REM This is the same on Mac or Windows.. 
react-native init AwesomeProject 

cd AwesomeProject 

REM You need to install the react package manager 
npm install -g rnpm 

REM Add the rnpm-plugin-windows into your package.json 
npm install --save-dev rnpm-plugin-windows 

REM This will create a "windows" folder in your project folder, 
REM the eqivalent of the ios and android folders. 
rnpm windows 

REM You will now have a windows folder with a AwesomeProject.sln file 
REM You need to start the packager which projects the Javascript bundle to the runtime 

react-native start 

REM Open the solution in VS and run it, and you will see your app! 
相關問題