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