因爲博主公司方案給定的React Native開發框架,近期自己開始了這個框架的學習之旅,就目前自己的感覺,這個框架真是強大的離譜啊,不說了,開幹。
第一步,React Native框架基本瞭解及環境配置
React Native 是 Facebook 推出的一個用 Java 語言就能同時編寫 ios,android,以及後臺的一項技術,用這一門技術,它可以做到實時熱更新.
React Native用iOS自帶的JavaScriptCore作爲JS的解析引擎,但並沒有用到JavaScriptCore提供的一些可以讓JS與OC互調的特性,而是自己實現了一套機制,這套機制可以通用於所有JS引擎上,在沒有JavaScriptCore的情況下也可以用webview代替
第二步,環境搭建(本人IOS出身,只說mac端)
1.安裝Homebrew
ruby -e "$(curl -fsSL https://raw.githubusercontent.com/Homebrew/install/master/install)"
brew -v 檢查是否安裝成功
2.安裝npm 和node.js
下載node.js安裝即可https://nodejs.org/en/download/
3.安裝watchMan(輔助開發工具,非必要安裝)
brew install watchman
wangxiaoshengdeMacBook-Air:~ mac$ brew install watchman
Error: Another active Homebrew process is already in progress.
Please wait for it to finish or terminate it to continue.
==>Installing dependencies for watchman: pcre
==>Installing watchman dependency: pcre
==>Downloading https://homebrew.bintray.com/bottles/pcre-8.39.yosemite.bottle.t
######################################################################## 100.0%
==>Pouring pcre-8.39.yosemite.bottle.tar.gz
�� /usr/local/Cellar/pcre/8.39: 203 files, 5.4M
==>Installing watchman
==>Downloading https://homebrew.bintray.com/bottles/watchman-4.7.0.yosemite.bot
######################################################################## 100.0%
==>Pouring watchman-4.7.0.yosemite.bottle.tar.gz
==>Using the sandbox
�� /usr/local/Cellar/watchman/4.7.0: 21 files, 428.8K
4.安裝flow,是一個javascript的靜態類型檢查器,建議安裝,方便找出代碼中可能存在的類型錯誤
wangxiaoshengdeMacBook-Air:~ mac$ brew install flow
Error: Another active Homebrew process is already in progress.
Please wait for it to finish or terminate it to continue.
==>Downloading https://homebrew.bintray.com/bottles/flow-0.33.0.yosemite.bottle
######################################################################## 100.0%
==>Pouring flow-0.33.0.yosemite.bottle.tar.gz
==>Caveats
Bash completion has been installed to:
/usr/local/etc/bash_completion.d
zsh completion has been installed to:
/usr/local/share/zsh/site-functions
==>Summary
�� /usr/local/Cellar/flow/0.33.0: 7 files, 4.9M
第二步:React Native 安裝
sudo npm install -g react-native-cli
wangxiaoshengdeMacBook-Air:~ mac$ sudo npm install -g react-native-cli
/usr/local/bin/react-native -> /usr/local/lib/node_modules/react-native-cli/index.js
[email protected] /usr/local/lib/node_modules/react-native-cli
├── [email protected] ([email protected], [email protected], [email protected], [email protected], [email protected])
└── [email protected] ([email protected], [email protected], [email protected], [email protected], [email protected])
wangxiaoshengdeMacBook-Air:~ mac$ ZZ
wangxiaoshengdeMacBook-Air:~ mac$ sudo npm install -g react-native-cli
Password:
/usr/local/bin/react-native -> /usr/local/lib/node_modules/react-native-cli/index.js
[email protected] /usr/local/lib/node_modules/react-native-cli
├── [email protected] ([email protected], [email protected], [email protected], [email protected], [email protected])
└── [email protected] ([email protected], [email protected], [email protected], [email protected], [email protected])
安裝成功會有以上提示.