4.管理RN版本庫
在開發(fā)中,會經(jīng)常的去控制React Native的版本庫,得以適配各種條件下的開發(fā),那該如何查看、控制ReactNative的版本呢?
**1 查看本地的React Native的版本**
命令行輸入
react-native --version
命令行效果
5000){failImgCache.clear();}failImgCache.push(this.getAttribute('src'));this.src='style/imgErr.gif';$(this).closest('.md-image').addClass('md-img-error').removeClass('md-img-loaded');this.onload=''" onload="loadedImgCache.push(this.getAttribute('src'));$(this).closest('.md-image').addClass('md-img-loaded').removeClass('md-img-error');" style="box-sizing: border-box; border-width: 0px 4px 0px 2px; border-right-style: solid; border-left-style: solid; border-right-color: transparent; border-left-color: transparent; vertical-align: middle; max-width: 100%; cursor: default;">
項目中查看react-native版本
5000){failImgCache.clear();}failImgCache.push(this.getAttribute('src'));this.src='style/imgErr.gif';$(this).closest('.md-image').addClass('md-img-error').removeClass('md-img-loaded');this.onload=''" onload="loadedImgCache.push(this.getAttribute('src'));$(this).closest('.md-image').addClass('md-img-loaded').removeClass('md-img-error');" style="box-sizing: border-box; border-width: 0px 4px 0px 2px; border-right-style: solid; border-left-style: solid; border-right-color: transparent; border-left-color: transparent; vertical-align: middle; max-width: 100%; cursor: default;">
**2 更新本地的react-native-cli的版本**
命令行輸入
npm update -g react-native-cli
5000){failImgCache.clear();}failImgCache.push(this.getAttribute('src'));this.src='style/imgErr.gif';$(this).closest('.md-image').addClass('md-img-error').removeClass('md-img-loaded');this.onload=''" onload="loadedImgCache.push(this.getAttribute('src'));$(this).closest('.md-image').addClass('md-img-loaded').removeClass('md-img-error');" style="box-sizing: border-box; border-width: 0px 4px 0px 2px; border-right-style: solid; border-left-style: solid; border-right-color: transparent; border-left-color: transparent; vertical-align: middle; max-width: 100%; cursor: default;">
**3 查詢react-native的npm包最新版本**
NPM的全稱是Node Package Manager ,是一個NodeJS包管理和分發(fā)工具,已經(jīng)成為了非官方的發(fā)布Node模塊(包)的標(biāo)準(zhǔn)。
命令行查詢npm包最新版本
npm info react-native
執(zhí)行命令
5000){failImgCache.clear();}failImgCache.push(this.getAttribute('src'));this.src='style/imgErr.gif';$(this).closest('.md-image').addClass('md-img-error').removeClass('md-img-loaded');this.onload=''" onload="loadedImgCache.push(this.getAttribute('src'));$(this).closest('.md-image').addClass('md-img-loaded').removeClass('md-img-error');" style="box-sizing: border-box; border-width: 0px 4px 0px 2px; border-right-style: solid; border-left-style: solid; border-right-color: transparent; border-left-color: transparent; vertical-align: middle; max-width: 100%; cursor: default;">
查看效果
npm info react-native >> D:\logcat.txt
5000){failImgCache.clear();}failImgCache.push(this.getAttribute('src'));this.src='style/imgErr.gif';$(this).closest('.md-image').addClass('md-img-error').removeClass('md-img-loaded');this.onload=''" onload="loadedImgCache.push(this.getAttribute('src'));$(this).closest('.md-image').addClass('md-img-loaded').removeClass('md-img-error');" style="box-sizing: border-box; border-width: 0px 4px 0px 2px; border-right-style: solid; border-left-style: solid; border-right-color: transparent; border-left-color: transparent; vertical-align: middle; max-width: 100%; cursor: default;">
查看當(dāng)前最新版本
5000){failImgCache.clear();}failImgCache.push(this.getAttribute('src'));this.src='style/imgErr.gif';$(this).closest('.md-image').addClass('md-img-error').removeClass('md-img-loaded');this.onload=''" onload="loadedImgCache.push(this.getAttribute('src'));$(this).closest('.md-image').addClass('md-img-loaded').removeClass('md-img-error');" style="box-sizing: border-box; border-width: 0px 4px 0px 2px; border-right-style: solid; border-left-style: solid; border-right-color: transparent; border-left-color: transparent; vertical-align: middle; max-width: 100%; cursor: default;">
**4 升級或者降級npm包的版本**
npm install --save react-native@0.41.1 (版本號)
譯注:從0.24版本開始,react-native還需要額外安裝react模塊,且對react的版本有嚴(yán)格要求,高于或低于某個范圍都不可以。本文無法在這里列出所有react native和對應(yīng)的react模塊版本要求,只能提醒讀者先嘗試執(zhí)行npm install,然后注意觀察安裝過程中的報錯信息,例如require react@某.某.某版本, but none was installed
,然后根據(jù)這樣的提示,執(zhí)行npm install react@^15.4.2 --save
。
5000){failImgCache.clear();}failImgCache.push(this.getAttribute('src'));this.src='style/imgErr.gif';$(this).closest('.md-image').addClass('md-img-error').removeClass('md-img-loaded');this.onload=''" onload="loadedImgCache.push(this.getAttribute('src'));$(this).closest('.md-image').addClass('md-img-loaded').removeClass('md-img-error');" style="box-sizing: border-box; border-width: 0px 4px 0px 2px; border-right-style: solid; border-left-style: solid; border-right-color: transparent; border-left-color: transparent; vertical-align: middle; max-width: 100%; cursor: default;">
升級react-native的npm版本后,打開該項目中的package.json文件,找到dependencies標(biāo)簽里邊我們把react-native的版本修改成最新版本
5000){failImgCache.clear();}failImgCache.push(this.getAttribute('src'));this.src='style/imgErr.gif';$(this).closest('.md-image').addClass('md-img-error').removeClass('md-img-loaded');this.onload=''" onload="loadedImgCache.push(this.getAttribute('src'));$(this).closest('.md-image').addClass('md-img-loaded').removeClass('md-img-error');" style="box-sizing: border-box; border-width: 0px 4px 0px 2px; border-right-style: solid; border-left-style: solid; border-right-color: transparent; border-left-color: transparent; vertical-align: middle; max-width: 100%; cursor: default;">
接下來就是執(zhí)行如下代碼進行安裝(注意請命令行切換到項目主文件夾):-這個安裝過程還是需要花點時間的
npm install
5000){failImgCache.clear();}failImgCache.push(this.getAttribute('src'));this.src='style/imgErr.gif';$(this).closest('.md-image').addClass('md-img-error').removeClass('md-img-loaded');this.onload=''" onload="loadedImgCache.push(this.getAttribute('src'));$(this).closest('.md-image').addClass('md-img-loaded').removeClass('md-img-error');" style="box-sizing: border-box; border-width: 0px 4px 0px 2px; border-right-style: solid; border-left-style: solid; border-right-color: transparent; border-left-color: transparent; vertical-align: middle; max-width: 100%; cursor: default;">
**5 更新項目templates文件(可選)**
新的npm包會包含更新在運行react-native init命令生成的一些動態(tài)文件,例如init創(chuàng)建項目的時候會生成iOS和Android的子項目,我們可以通過以下的命令進行獲取最新的代碼
命令行執(zhí)行,如果有提示按yes
react-native upgrade
5000){failImgCache.clear();}failImgCache.push(this.getAttribute('src'));this.src='style/imgErr.gif';$(this).closest('.md-image').addClass('md-img-error').removeClass('md-img-loaded');this.onload=''" onload="loadedImgCache.push(this.getAttribute('src'));$(this).closest('.md-image').addClass('md-img-loaded').removeClass('md-img-error');" style="box-sizing: border-box; border-width: 0px 4px 0px 2px; border-right-style: solid; border-left-style: solid; border-right-color: transparent; border-left-color: transparent; vertical-align: middle; max-width: 100%; cursor: default;">
5.WebStom設(shè)置RN代碼提示
安裝[ReactNative-LiveTemplate-master](https://github.com/virtoolswebplayer/ReactNative-LiveTemplate)插件,window的用戶建議使用第一種方式安裝
5000){failImgCache.clear();}failImgCache.push(this.getAttribute('src'));this.src='style/imgErr.gif';$(this).closest('.md-image').addClass('md-img-error').removeClass('md-img-loaded');this.onload=''" onload="loadedImgCache.push(this.getAttribute('src'));$(this).closest('.md-image').addClass('md-img-loaded').removeClass('md-img-error');" style="box-sizing: border-box; border-width: 0px 4px 0px 2px; border-right-style: solid; border-left-style: solid; border-right-color: transparent; border-left-color: transparent; vertical-align: middle; max-width: 100%; cursor: default;">
管理RN版本庫
最后編輯于 :
?著作權(quán)歸作者所有,轉(zhuǎn)載或內(nèi)容合作請聯(lián)系作者
【社區(qū)內(nèi)容提示】社區(qū)部分內(nèi)容疑似由AI輔助生成,瀏覽時請結(jié)合常識與多方信息審慎甄別。
平臺聲明:文章內(nèi)容(如有圖片或視頻亦包括在內(nèi))由作者上傳并發(fā)布,文章內(nèi)容僅代表作者本人觀點,簡書系信息發(fā)布平臺,僅提供信息存儲服務(wù)。
【社區(qū)內(nèi)容提示】社區(qū)部分內(nèi)容疑似由AI輔助生成,瀏覽時請結(jié)合常識與多方信息審慎甄別。
平臺聲明:文章內(nèi)容(如有圖片或視頻亦包括在內(nèi))由作者上傳并發(fā)布,文章內(nèi)容僅代表作者本人觀點,簡書系信息發(fā)布平臺,僅提供信息存儲服務(wù)。
相關(guān)閱讀更多精彩內(nèi)容
- 很多使用CocoPods的朋友通常認(rèn)為是從網(wǎng)上下載資源到工程管理,但是不知道可以管理本地資源 一.了解CocoPo...
- 書寫規(guī)范 關(guān)于Podfile的書寫規(guī)范,其實作為開發(fā)者不必每次都重復(fù)寫著類似又不同的例子,我建議給出最官方的地址,...
- 近日小編發(fā)現(xiàn),由孫紅雷宣傳代言的全新哈弗H6汽車品牌刷屏央視廣告欄目,搶占廣告黃金時機,廣告一經(jīng)播出就受到廣大電視...