react native
注:本文是我在开发过程中遇到问题解决方法的总结,之后会持续更新,希望帮助到更多的学习者。文中有不妥的地方希望指出共同学习,同时欢迎大神补充。(之后我会放出自己开发整理的笔记和demo)欢迎持续喜欢关注 star。 错误1:
Paste_Image.png
错误2: 这个说明你要跳转的页面缺少子控件。所以你要在里面添加东西比如加个: <View></View>
警告3:调试警告看下报的警告就知道调试程序在这个窗口导致运行缓慢,所以建议你换一个单独新的窗口进行调试 警告4:解决方法就是你的Xcode没有适配HTTPS iOS9的 加上: <key>NSAppTransportSecurity</key>
<dict>
<key>NSAllowsArbitraryLoads</key>
<true/>
</dict>
错误4:这个很神奇。遇到了不要紧张多按 ?R几下或者把模拟器上的项目删除之后重新加载一般就会解决 错误5: 认真看下错误信息,上面说你忘记返回值了 所以你的函数中少了一个return();
错误6: 错误7:SyntaxError: SyntaxError /Users/zhaopengsong/Desktop/ReactNative/BuyDemo/Component/Main/ZPMain.js: JSX value should be either an expression or a quoted JSX text (107:22)
语法错误,JSX语法必须用{}对变量进行赋值:如 title=titleName 换为title={titleName} 或者检查下有没有其他的语法错误,比如少了 逗号 多了分号 这些低级错误
错误8Requiring unknown module "undefined".If you are sure the module is there,try restarting the packager or running "npm install"
这个错误我的解决思路是:之前改过什么,撤回,一般是用到了错误的react-native 方法导致的。
错误9:原因:没有启动后台react-Native 服务。即终端
Paste_Image.png
错误10: 如果你遇到了列如九宫格不自动换行的情况,检查一下样式里面有没有这两句话 错误11:
ExceptionsManager.js:63 Expected a component class,got [object Object]
解决方法: You need to rename your commonView class toCommonView ,the class must becapitalize
错误12:
NSURLErrorDomain
这是你请求的URL错误。要是 错误13:创建新项目,react-native init 项目名命令长时间无响应,或报错shasum check failedreact-native命令行从npm官方源拖代码时会遇上麻烦。请将npm仓库源替换为国内镜像: npm config set registry https://registry.npm.taobao.org --global
npm config set disturl https://npm.taobao.org/dist --global
另,执行init时切记不要在前面加上sudo 错误14:修改8081默认端口号的两种方式 (1)启动项目时react-native start --port 8083 错误15:
Application NewsDemo has not been registered.
This is either due to a require() error during initialization
or
failure to call AppRegistry.registerComponent.
错误原因是端口冲突。解决方法是看错误14 其次解决方法是: 1、终端
2、cd 到项目目录
3、react-native start
4、lsof -n -i4TCP:8081 //这句可以看打印出8081端口下的服务
5、kill -9 <PID> //终止你其他占用端口
如图: 错误16:
如果你遇到了这个问题,并解决了。希望能在下面留言帮助更多的人。感谢!(我的错误原因是require路径出错,我是换用URI 加载image资源解决的) 错误17: 错误出现执行 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,0)">Not Exist
解决方法:
1、尝试reset一下 模拟器之后再 react-native run-ios 2、尝试执行 react-native upgrade 然后一路enter再 react-native run-ios 试试?解决方法参考链接:连接1,连接2 3、在这里感谢:LeeyaWang提供自己的解决思路:希望对之后遇到此问题的同学有所帮助! 步骤是:
1、首先删除node_modules
2、修改package.json中react-native的版本为0.44.3 react为16.0.0-alpha.6
3、react-native run-ios 就可以啦 后来是出现我发你的问题 我觉得 应该是我这边vpn的问题,所以我重启了一下电脑 然后重置了模拟器 就可以了
友情提示:如果你用的ReactNative版本为0.45.1,新建项目之后运行出现这个错误:
'boost/iterator/iterator_adaptor.hpp' file not found
image.png
方法2、新建项目指定版本: 错误18: 解决:
var View = React.View;
/* later... */
propTypes: {
...View.propTypes,myProp: PropTypes.string
}
错误19:(这个错误我的解决方法是新建项目,把组件放到新项目,重新安装第三方,然后
|