我在终端中Attempted import error: 'Redirect' is not exported from 'react-router-dom'.
运行时得到了npm run start
。
我重新安装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",
任何帮助表示赞赏,谢谢。