ReactNative TabNavigator

TabNavigator的简单使用
1.引入 TabNavigator import {TabNavigator} from 'react-navigation'
2.创建多个组件
3.通过TabNavigator做路由映射

class RecentChatsScreen extends Component{
    render(){
        return List of recent chats
    }
}
class AllContactsScreen extends Component{
    render(){
        const {navigate} = this.props.navigation;
        return(
            
                this is a test
                

4.把RecentChatsScreen作为screen,
const SimpleApp = StackNavigator({
Main:{screen:MainScreentNavigator},
Chat:{screen:ChatScreen}
});
4.然后设置navigationOptions
所以设置导航标题
MainScreentNavigator.navigationOptions={
title:'Message',
}

示例代码:
/**
 * Sample React Native App
 * https://github.com/facebook/react-native
 * @flow
 */

import React, { Component } from 'react';
import {
  AppRegistry,
  StyleSheet,
  Text,
  View,
    Image,
    Dimensions,
    TextInput,
    ScrollView,
    FlatList,
    SectionList,
    Button
} from 'react-native';

import {StackNavigator,TabNavigator} from 'react-navigation';

class  HomeScreen extends Component{
    static navigationOptions=({navigation}) =>({
        title:'Welcome',
        headerRight:

你可能感兴趣的:(ReactNative TabNavigator)