我有带有以下代码的 React Router v5:索引.jsimport React from 'react';import ReactDOM from 'react-dom';import App from './App';import * as serviceWorker from './serviceWorker';import { MuiThemeProvider, createMuiTheme } from '@material-ui/core/styles';const muiTheme = createMuiTheme({ palette: { primary: { main: '#2196f3' } }, overrides: { MUIDataTableSelectCell: { fixedHeaderCommon: { backgroundColor: 'transparent', }, }, MuiTableCell: { sizeSmall: { padding: '6px 0 6px 16px' } }, MuiTableRow: { hover: { cursor: 'pointer' } } }});ReactDOM.render(<MuiThemeProvider theme={muiTheme}><App /></MuiThemeProvider>, document.getElementById('root'));serviceWorker.unregister();应用程序.jsimport { // BrowserRouter as Router, Switch, Route, Router, // Link, // useRouteMatch, // useParams} from "react-router-dom";import history from 'history/browser';import Dashboard from './common/components/Dashboard';import Login from './common/components/Login';import Test from './common/components/Test';<Router history={history}> <Switch> <Route path="/test" component={Test} /> <Route path="/login" component={Login} /> <Route path="/" exact component={Dashboard} /> <Route component={Error404} /> </Switch></Router>每当我使用正确的凭据提交时,我都会从带有 JWT 令牌的服务器获得 200 个响应代码,但在history.push('/test');登录功能后,我没有获得路由匹配,/test而是会Error404捕获所有路由。这怎么可能?
添加回答
举报
0/150
提交
取消