react-native navigator
来源:互联网 发布:网络运行维护服务合同 编辑:程序博客网 时间:2024/05/29 12:30
react-native 的导航器是比较复杂的概念,这里记录一下
renderImages: function() { return ( <NavigatorIOS style={styles.navigator} initialRoute={{ component: MyView, title: 'My View Title', passProps: { myProp: 'foo' }, backButtonTitle: 'Custom Back', rightButtonTitle: 'Cancel', leftButtonTitle: 'back', }}/> ); },
上面这段代码,当renderImages方法被触发的时候,导航器就会加载MyView视图
下面是MyView的定义:
var MyView = React.createClass({ render: function(){ return ( <ScrollView contentContainerStyle={[styles.contentContainer]}> <View style={styles.flexContainer}> <TouchableHighlight onPress={this.bigImage} style={{flex:1,height:100}}> <Image style={styles.logo} source={{uri: 'http://facebook.github.io/react/img/logo_og.png'}} /> </TouchableHighlight> </View> </ScrollView> ); }});
这样一个的视图
根据这个,其实可以创造出更深一层
增加bigImage方法查看大图
bigImage : function(){ this.props.navigator.push({ title: 'title', component: NavigatorIOSExample, rightButtonTitle: 'test1', leftButtonTitle: 'back2', onLeftButtonPress:() => this.props.navigator.pop(), onRightButtonPress:()=> AlertIOS.alert( 'Foo Title', this.props.myProp ) }); },
此外可以看出onLeftButtonPress方法的作用是返回上个视图,
另外,可以通过passProps属性来进行view之间的参数传递
0 0
- react-native navigator
- react-native--Navigator
- React Native之Navigator
- React Native[Navigator]
- React-Native之Navigator
- react-native navigator
- react-native-tab-navigator
- React Native Navigator
- react native Navigator
- React Native Navigator
- React-native navigator
- React Native]React Native组件之Navigator
- react-native Navigator 填坑
- React Native的Navigator详解
- 学习react-native之Navigator
- 关于react-native navigator 记录
- React-Native学习十八:Navigator
- React-native Navigator导航跳转
- 动态生成 fastCall(易语言 调用WKE浏览器)
- Synchronized关键字--总结于《Java多线程编程核心技术》
- 【tyvj1032】零用钱
- eclipse 很好用的高频快捷键
- 欢迎使用CSDN-markdown编辑器
- react-native navigator
- 八皇后问题
- 如何优雅的使用 ubuntu
- matplotlib利用scatter绘制彩色图像:NameError: name 'array' is not defined
- 正则表达式
- HDU 1036 Average is not Fast Enough!【水】
- 空指针异常的原因分析
- Spring之Ioc详解01
- 初识CSS--常用元素总结(五)-表格和列表