关于react native 一些常见错误的积累
最近在学习rn的时候碰到一些奇葩的问题,在这里总结一下,日后可以有据可查
在完成所有的配置之后也就是执行了
react native //项目启动
react-native init AwesomeProject
cd AwesomeProject
react-native run-ios
报错: 找不到index.os文件
解决 在AwesomeProject 文件下的AppDelegate.m 文件的@“index.os”改为 @”http://localhost:8081/index.ios.bundle?platform=ios&dev=true”
报错:can’t find variable:title
错误代码
initialRoute={(
title:'首页',
Component:HomeView
)}
正确
initialRoute={{
title:'首页',
Component:HomeView
}}
报错:onlyChild must be passed a children with exactly one child
遍找代码也找不到错误,页面语法和代码OK,知道我删掉了一行注释的代码
原代码:
// {this._renderContent('#21551C', '下载页面', this.state.presses)}
<NavigatorIOS
style={styles.container}
initialRoute={{
title: '历史',
component: NewsView,
//rightButtonIcon: require('image!icon_tabbar_onsite'),
}}
/>
修改后:删掉注释的代码运行OK