首页 > 其他 > 详细

React Navigation基本用法

时间:2018-09-23 12:23:55      阅读:158      评论:0      收藏:0      [点我收藏+]
/**
 * Created by apple on 2018/9/23.
 */
import React, { Component } from ‘react‘;
import {AppRegistry, View, Text,Button } from ‘react-native‘;
import { StackNavigator } from ‘react-navigation‘;

const HomeScreen = ({navigation}) => (
  <View style={{ flex: 1, alignItems: ‘center‘, justifyContent: ‘center‘ }}>
    <Text>Home Screen</Text>
      <Button title="Go to details" onPress={()=>navigation.navigate(‘Details‘)}/>
  </View>
);

const DetailsScreen = () => (
  <View style={{ flex: 1, alignItems: ‘center‘, justifyContent: ‘center‘ }}>
    <Text>Details Screen</Text>
  </View>
);


const RootNavigator = StackNavigator({
Home:{
    screen:HomeScreen,
    navigationOptions:{
        headerTitle:‘Home‘,
    },
},
Details:{
    screen:DetailsScreen,
    navigationOptions:{
        headerTitle:‘Details‘,
    },
},
});
export default class qrHello extends Component {

  render() {
    return(
        <RootNavigator/>
    );
  }
}
AppRegistry.registerComponent(‘qrHello‘, () => qrHello);

技术分享图片技术分享图片

React Navigation基本用法

原文:https://www.cnblogs.com/zqrios/p/9692375.html

(0)
(0)
   
举报
评论 一句话评论(0
关于我们 - 联系我们 - 留言反馈 - 联系我们:wmxa8@hotmail.com
© 2014 bubuko.com 版权所有
打开技术之扣,分享程序人生!