RN開發(fā)過程中會(huì)涉及到iOS和安卓?jī)蓚€(gè)端的適配,尤其是TabBar和Navigatior的使用方面很容易出錯(cuò)。
最開始的學(xué)習(xí)中都是使用TabBarIOS和NavigatorIOS來(lái)實(shí)現(xiàn)框架的搭建,但是這兩個(gè)組件只能適用在iOS端,安卓端是無(wú)法使用的,所以就得使用TabNavigator和Navigator來(lái)實(shí)現(xiàn)兩個(gè)端的適配開發(fā)。
1、安裝TabNavigator,如果直接進(jìn)入到項(xiàng)目的根目錄然后就進(jìn)行安裝的話,會(huì)報(bào)錯(cuò)!

正確步驟:從控制臺(tái)進(jìn)入到項(xiàng)目根目錄以后
react-native link?||rnpm link一下然后再
npm i react-native-tab-navigator --save
2、使用Navigator

直接像上圖這樣引入Navigator,運(yùn)行時(shí)會(huì)報(bào)錯(cuò):
Navigator?is?deprecated?and?has?been?removed?from?this?package.?It?can?now?be?installed?'?+? 'and?imported?from?`react-native-deprecated-custom-components`?instead?of?`react-native`.?'?+? 'Learn?about?alternative?navigation?solutions?at?http://facebook.github.io/react-native/docs/navigation.html'
此時(shí)我們需要通過引用:
react-native-deprecated-custom-components 來(lái)導(dǎo)入 Navigator 組件
正確步驟:
1、打開程序的根目錄(也就是和 Package.json 同級(jí)的目錄)
2、使用cmd 命令工具
輸入命令: ? ?npm ?installreact-native-deprecated-custom-components ?--save?
在使用Navigator的地方引用便可使用。
引用方式:import {Navigator} from "react-native-deprecated-custom-components"
注意:在引用時(shí) 一定在導(dǎo)入 Navigator的時(shí)候加上 {} ?要不然會(huì)報(bào)錯(cuò)。
