在终端中运行 npm run start
时,出现以下错误。
尝试导入错误: “ Redirect”没有从“ response-router-dom”导出。
我已经重新安装了 node_modules
,react-router-dom
,react-router
。也重新启动了终端和我的计算机,但问题仍然存在。
我的代码:
import React from 'react';
import { Switch, Redirect } from 'react-router-dom';
import { RouteWithLayout } from './components';
import { Minimal as MinimalLayout } from './layouts';
import {
Login as LoginView,
Dashboard as DashboardView,
NotFound as NotFoundView
} from './views';
const Routes = () => {
return (
<Switch>
<Redirect
exact
from="/"
to="/dashboard"
/>
<RouteWithLayout
component={routeProps => <LoginView {...routeProps} data={data} />}
exact
layout={MinimalLayout}
path="/login"
/>
<Redirect to="/not-found" />
</Switch>
);
};
export default Routes;
这是我进口的 package.json
:
"react-router": "^6.0.0-beta.0",
"react-router-dom": "^6.0.0-beta.0",