加入收藏 | 设为首页 | 会员中心 | 我要投稿 李大同 (https://www.lidatong.com.cn/)- 科技、建站、经验、云计算、5G、大数据,站长网!
当前位置: 首页 > 百科 > 正文

在React Native中使用导航(ios)

发布时间:2020-12-15 04:38:11 所属栏目:百科 来源:网络整理
导读:在React Native中使用导航(ios) /** * Sample React Native App * https://github.com/facebook/react-native */'use strict';var React = require('react-native');var { AppRegistry,StyleSheet,Text,View,NavigatorIOS,TouchableHighlight} = React;// 1.

在React Native中使用导航(ios)


/**
 * Sample React Native App
 * https://github.com/facebook/react-native
 */
'use strict';
var React = require('react-native');
var {
  AppRegistry,StyleSheet,Text,View,NavigatorIOS,TouchableHighlight
} = React;

// 1.GithubFinder
var NavDemo = React.createClass({
  onRightButtonPress: function() {
    this.refs.nav.push({
      title: 'From Right',component: ForRightScene
    })
  },render () {
    return (
      <NavigatorIOS ref="nav"
        style={styles.container}
        initialRoute={{
          component: HomeScene,title: 'NavigatorIOS Demo',rightButtonTitle: 'PUSH',onRightButtonPress: this.onRightButtonPress
        }} />
    );
  }
});

// 2.HomeScene
var HomeScene = React.createClass({
  onPress() {
    this.props.navigator.push({
      title: 'From TouchableHighlight',component: ForTouchScene
    });
  },render() {
    return (
      <View style={[styles.scene,{backgroundColor:'#DAF6FF'}]}>
      <TouchableHighlight onPress={this.onPress}>
        <Text>Welcome to the NavigatorIOS Demo. Press here!</Text>
      </TouchableHighlight>
      </View>
    );
  }
});

// 3.ForRightScene
var ForRightScene = React.createClass({
  render() {
    return (
      <View style={[styles.scene,{backgroundColor:'#FFF1E8'}]}>
        <Text>You came here from the "right" button!</Text>
      </View>
    );
  }
});

// 4.ForTouchScene
var ForTouchScene = React.createClass({
  render() {
    return (
      <View style={[styles.scene,{backgroundColor: '#ECF6E8'}]}>
        <Text>You came here from the TouchableHighlight!</Text>
      </View>
    );
  }
});

var styles = StyleSheet.create({
  container: {
    flex: 1
  },scene: {
    padding: 10,paddingTop: 74,flex: 1
  }
});

AppRegistry.registerComponent('rctnavigator',() => NavDemo);

(编辑:李大同)

【声明】本站内容均来自网络,其相关言论仅代表作者个人观点,不代表本站立场。若无意侵犯到您的权利,请及时与联系站长删除相关内容!

    推荐文章
      热点阅读