React-native 学习笔记(三)

来源:互联网 发布:中国宇航出版社 知乎 编辑:程序博客网 时间:2024/06/05 18:30

关于react native 一些常见错误的积累

最近在学习rn的时候碰到一些奇葩的问题,在这里总结一下,日后可以有据可查

在完成所有的配置之后也就是执行了

react native  //项目启动react-native init AwesomeProjectcd AwesomeProjectreact-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

0 0
原创粉丝点击