React Router在gh页面上传时出现问题



在gh页面上传项目时遇到问题。这是我的应用程序:

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页面上不起作用。它返回404页。其他一切都很好。如有任何帮助,将不胜感激

终于找到了有效的解决方案-用HashRouter 取代了BrowserRouter

最新更新