Reactjs 在gh页面上上载时,React路由器出现问题
我在gh-pages上上载项目时遇到问题。这是我的应用程序:Reactjs 在gh页面上上载时,React路由器出现问题,reactjs,github-pages,router,Reactjs,Github Pages,Router,我在gh-pages上上载项目时遇到问题。这是我的应用程序: function App() { return ( <> <Navbar/> <Switch> <Route exact path="/Hotels" component={Home}/> <Route exact path="/Hotels/all" component={
function App() {
return (
<>
<Navbar/>
<Switch>
<Route exact path="/Hotels" component={Home}/>
<Route exact path="/Hotels/all" component={Hotels}/>
<Route exact path="/Hotels/all/:hotelId" component={Hotel}/>
<Route exact path="/Hotels/all/:hotelId/rooms" component={Rooms}/>
<Route exact path ="/Hotels/all/:hotelId/rooms/:roomId" component={Room}/>
<Route exact path ="/Hotels/all/:hotelId/rooms/:roomId/book" component={Checkout}/>
<Route exact path ="/Hotels/successpay" component={SuccessPay}/>
<Route exact path ="/Hotels/errorpay" component={ErrorPay}/>
<Route component={Error}/>
</Switch>
<Footer/>
</>
);
}
函数应用程序(){
返回(
);
}
问题是我的最后3条路由在gh-pages上不起作用。它返回404页。其他一切正常。如果您能提供帮助,我们将不胜感激。最终找到了有效的解决方案-将BrowserRouter替换为HashRouter