使用NavigationContainer无法显示其他屏幕

时间:2020-03-26 02:06:23

标签: reactjs react-native react-router react-navigation react-router-v4

如果App.js中的“我的功能主屏幕”和“设置屏幕”可以显示该屏幕,并且当我单击选项卡时我将单独的屏幕显示为不同的.js时,则无法显示

App.js

import { NavigationContainer } from '@react-navigation/native';
import { createMaterialBottomTabNavigator } from '@react-navigation/material-bottom-tabs';
import HomeScreen from './screens/HomeSreen';
import SettingsScreen from './screens/SettingsScreen';

const Tab = createMaterialBottomTabNavigator();

export default function App() {
  return (
    <NavigationContainer>
      <Tab.Navigator>
        <Tab.Screen name="Home" component={HomeScreen} />
        <Tab.Screen name="Settings" component={SettingsScreen} />
      </Tab.Navigator>
    </NavigationContainer>
  );
}

HomeScreen.js

import React from 'react';
import { Text, View } from 'react-native';


function HomeScreen() {
    return (
      <View style={{ flex: 1, justifyContent: 'center', alignItems: 'center' }}>
        <Text>Home!</Text>
      </View>
    );
  }

SettingsScreen.js

import React from 'react';
import { Text, View } from 'react-native';





  function SettingsScreen() {
    return (
      <View style={{ flex: 1, justifyContent: 'center', alignItems: 'center' }}>
        <Text>Settings!</Text>
      </View>
    );
  }

0 个答案:

没有答案