我试图设置一个 react-native 项目,在该项目中,我只尝试在 app.js 中使用包 react-navigation 创建堆栈导航器,我按照本指南https://reactnavigation.org/docs/getting-started然后进入https://reactnavigation.org/docs/hello-react-navigation但我收到错误
编译失败。D:/Visual Studio Code/Resturant Review/food/App.js Module not found: Can't resolve '@react-navigation/stack' in 'D:\Visual Studio Code\Resturant Review\food' 这是我的代码:
//app.js
import * as React from 'react';
import { View, Text } from 'react-native';
import { NavigationContainer } from '@react-navigation/native';
import { createStackNavigator } from '@react-navigation/stack';
function HomeScreen() {
return (
<View style={{ flex: 1, alignItems: 'center', justifyContent: 'center' }}>
<Text>Home Screen</Text>
</View>
);
}
const Stack = createStackNavigator();
function App() {
return …Run Code Online (Sandbox Code Playgroud)