这是http://localhost:3000/Constitution/的网址
它添加了一个额外的/,所以当我点击另一个路由时,它会附加到这个路由上,而不是发送给我另一个URL。
这是我的路由器
import React from 'react';
import { BrowserRouter, Route, Switch} from 'react-router-dom';
import Home from './routers/index';
import Contact from './routers/contact';
import About from './routers/about';
import Executives from './routers/executives';
import Constitution from './routers/constitution';
const AppRouter = () => {
return <BrowserRouter>
<div>
<Switch>
<Route path="/" component={Home} exact={true}/>
<Route path="/Contact" component={Contact}/>
<Route path="/About" component={About}/>
<Route path="/Executives" component={Executives}/>
<Route path="/Constitution" component={Constitution}/>
</Switch>
</div>
</BrowserRouter>
}
export default AppRouter;发布于 2020-11-19 23:04:15
试试这个:<Route exact path="/" component={Home}/>
而不是这个:<Route path="/" component={Home} exact={true}/>
https://stackoverflow.com/questions/64909054
复制相似问题