我想在HomeScreen中只打开TrackTest屏幕作为模态,我试着按照嵌套的导航器文档来做,但我做错了什么。有什么方法可以做到这一点吗?谢谢你。
enter code here
import React from 'react';
import { NavigationContainer } from '@react-navigation/native';
import { createStackNavigator } from '@react-navigation/stack';
import { WelcomeScreen as WelcomeScreen } from './WelcomeScreen';
import { LoginScreen } from './LoginScreen';
import { SignUpScreen } from './SignUpScreen';
import { ForgotPasswordScreen } from './ForgotPasswordScreen';
import { UserInfoScreen } from './UserInfoScreen';
import HomeScreen from './HomeScreen'
import { TrackTest } from './TrackScreen';
const { Navigator, Screen } = createStackNavigator();
const HomeNavigator = () => (
<Navigator headerMode='none'
>
<Screen name='Welcome' component={WelcomeScreen} />
<Screen name='Login' component={LoginScreen} />
<Screen name='Forgot' component={ForgotPasswordScreen} />
<Screen name='SignUp' component={SignUpScreen} />
<Screen name='UserInfo' component={UserInfoScreen} />
<Screen name='Home' component={HomeScreen} />
<Screen name='TrackT' component={TrackTest} />
</Navigator>
);
export const AppNavigator = () => (
<NavigationContainer>
<HomeNavigator />
</NavigationContainer>
);
https:/reactnavigation.orgdocsmodal 你可以像文档中说的那样以模态方式打开一个屏幕,通过给 mode="modal"
到堆栈导航器。