React Native常用錯誤集合


1.Cannot read property 'throwIfClosureRequired' of undefined (While processing preset: "/Users/poet/Documents/rn_project/DouBan/node_modules/babel-preset-react-native/index.js")

解決辦法:
If not work try this solution.


i) delete node_module folder.


ii) Open your package.json and change the devDependencies to:
"devDependencies":

{
...


"babel-preset-react-native": "4.0.0",


...
},


Then run npm install.
It's worked for me.

 

2.如何添加導航控制器

yarn add react-navigation   //添加導航控制器
yarn add react-native-vector-icons //添加iconFont,將這個Module下的Font的文件夾中的字體復制到Xcode的項目中去,並添加到Resource中,才會有效。

參考鏈接:https://github.com/oblador/react-native-vector-icons/issues/328

 

3.Module `react-navigation` does not exist in the Haste module map or in these directories(導航控制器已經添加過了,但是還報這個錯)

解決辦法:
先卸載這個模塊: npm uninstall react-navigation
然后重新安裝: yarn add react-navigation

參考鏈接:https://www.jianshu.com/p/df41b5a7841d

 

4.(添加自定義字體)Getting Started with NativeBase

a.瀏覽到node_modules/react-native-vector-icons目錄,然后選中 Fonts 目錄,將Fonts目錄中的所有文件拷貝到工程文件目錄下,然后將Fonts目錄拖到工程文件中,記得勾選Create Groups復選框。

b.編輯Info.plist文件,添加自定義字體的名稱。

參考鏈接:http://nativebase.io/docs/v0.3.0/getting-started

 

5. 添加Native Base

//首先在項目根目錄下執行
npm install native-base --save

//由於native base依賴react-native-vector-icons,所以需要安裝react-native-vector-icons
npm install react-native-vector-icons --save
//添加依賴react-native-vector-icons到原生工程 react-native link react-native-vector-icons

 


免責聲明!

本站轉載的文章為個人學習借鑒使用,本站對版權不負任何法律責任。如果侵犯了您的隱私權益,請聯系本站郵箱yoyou2525@163.com刪除。



 
粵ICP備18138465號   © 2018-2025 CODEPRJ.COM