React-native開發(fā)記錄

React-Native學習資料中文版
react-native組件生命周期
es5-es6寫法對照表

一、

Failed to install the requested application
An application bundle was not found at the provided path.
Provide a valid path to the desired application bundle.
Print: Entry, ":CFBundleIdentifier", Does Not Exist

Command failed: /usr/libexec/PlistBuddy -c Print:CFBundleIdentifier build/Build/Products/Debug-iphonesimulator/ReactNativexx.app/Info.plist
Print: Entry, ":CFBundleIdentifier", Does Not Exist
示意圖

解決:
用--version參數(shù)創(chuàng)建指定版本的項目。例如react-native init DemoApp --version 0.44.3注意版本號必須精確到兩個小數(shù)點。
項目創(chuàng)建好之后:執(zhí)行:react-native run-ios

如果是下載的項目,則需要npm install(安裝node_modules文件夾), 然后修改package.json里面的react-native和react如下:

修改react-native和react到指定版本

二、

No bundle URL present

Make sure you’re running a packager server or have included a .jsbundle file in your application bundle
(工程里面main.jsbunddle不存在|紅色的)
錯誤圖

解決:網(wǎng)上找的辦法:
1.重啟模擬器
2.設置網(wǎng)絡為自動代理
3.重啟電腦
4.模擬器正常運行的時候:npm install 然后react-native run-ios

都沒用!!!

折騰了好久,終于找到解決方案:


cd /Users/macofethan/Desktop/DemoApp/ios
npm start
//(curl http://localhost:8081/index.ios.bundle -o main.jsbundle)(忽略這個)
示意圖

示意圖

然后在模擬器中點擊reload JS

三、can't find simulator ...

原因:連接了未解鎖的真機 或者模擬器未啟動 從xcode啟動就可以了

四、如圖:

報錯圖
報錯圖二
導入ReadPage就報錯

原因:導入一個.js文件就報這個錯,路徑檢查了也是對的,還不知道是什么原因: 最后發(fā)現(xiàn)是導入的文件有問題

五、如圖:

示意圖

原因:沒有父視圖

六、如圖:

示意圖

原因:style語法錯誤

七、如圖:

示意圖

原因:圖上已經(jīng)寫明了 退出 重進

八、如圖:

示意圖
屏幕快照 2017-07-17 上午9.32.56.png
示意圖

原因:導入Prop'Types AppRegistry出錯

九、如圖,npm start未執(zhí)行

屏幕快照 2017-07-17 上午10.10.03.png

十、

屏幕快照 2017-07-17 上午9.45.25.png

這是因為版本升級到0.43以上的話,Navigator不能直接從react-native里面獲取了

解決:

npm install react-native-deprecated-custom-components --save

//然后在引用的地方導入:
import {Navigator} from 'react-native-deprecated-custom-components';

或者使用NavigatorIOS

十一、

導出組件的方式:

1. export default class..
2. module.exports = CzyScene;

十二、

示意圖

原因:使用了ES5寫狀態(tài)機

  getInitialState(){

    return{

      selectedTabItem:0
    }
  }

解決辦法:使用ES6的寫法:

    constructor(props) {
        super(props);
        this.state = {
            selectedTabItem: 'contacts'
        };
    }

十三、

fetch的時候 body:fromData: can't find variable....

十四、

自定義組件或者系統(tǒng)組件首字母小寫了
最后編輯于
?著作權歸作者所有,轉載或內(nèi)容合作請聯(lián)系作者
【社區(qū)內(nèi)容提示】社區(qū)部分內(nèi)容疑似由AI輔助生成,瀏覽時請結合常識與多方信息審慎甄別。
平臺聲明:文章內(nèi)容(如有圖片或視頻亦包括在內(nèi))由作者上傳并發(fā)布,文章內(nèi)容僅代表作者本人觀點,簡書系信息發(fā)布平臺,僅提供信息存儲服務。

相關閱讀更多精彩內(nèi)容

友情鏈接更多精彩內(nèi)容