我正在尝试使用 React Native 为 Web 应用程序配置 React-navigation。为此,我在 NavigationContainer 上设置了链接选项,以便我可以使用以下代码从浏览器 URL 访问我的页面:
const linking = {
prefixes: ['http://localhost:8080/', 'http://localhost:8080', 'localhost:8080'],
// prefixes: [prefix],
config: {
screens: {
SignIn: "SignIn",
SignUp: "SignUp",
Landing: '*',
},
}
};
function AppContainer() {
return (
<NavigationContainer linking={linking} fallback={<Text>Loading...</Text>}>
<AppStack.Navigator>
<AppStack.Screen name="SignIn" component={SignInPage}/>
<AppStack.Screen name="Landing" component={LandingPage}/>
<AppStack.Screen name="SignUp" component={SignUpPage}/>
<AppStack.Screen name="Home" component={HomePage}/>
</AppStack.Navigator>
</NavigationContainer>
);
}Run Code Online (Sandbox Code Playgroud)
当我转到“http://localhost:8080/”时,我被重定向到“http://localhost:8080/SignIn”(这很好),并且应用程序正在运行。问题是,如果我从浏览器访问“http://localhost:8080/SignIn”,我会收到“Cannot GET /SignIn”,并且该应用程序无法正常工作...
我正在使用这些版本:
"@react-navigation/bottom-tabs": "^5.11.1",
"@react-navigation/native": "^5.8.9",
"@react-navigation/stack": "^5.12.5",
Run Code Online (Sandbox Code Playgroud) deep-linking webpack-dev-server react-native react-navigation react-native-web