Warning: file_get_contents(/data/phpspider/zhask/data//catemap/3/reactjs/22.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Reactjs 在gh页面上上载时,React路由器出现问题_Reactjs_Github Pages_Router - Fatal编程技术网

Reactjs 在gh页面上上载时,React路由器出现问题

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={

我在gh-pages上上载项目时遇到问题。这是我的应用程序:

    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