繁体   English   中英

当我使用 github 个页面托管我的 React 应用程序时,React Router dom 不工作?

[英]React Router dom is not working when I hosted my React App with github pages?

导入'./App.css';

从 './component/NavBar.component' 导入 NavBar;

从 './component/main.component' 导入 Main;

从 './component/footer.component' 导入页脚;

import { Routes, Route, Link } from "react-router-dom";

从'./component/NavbarComponent/about.component'导入关于;

从 './component/NavbarComponent/hire.component' 导入 Hire;

从'./component/NavbarComponent/suport.component'导入支持;

function App() { 返回 (

  <Routes>
    <Route exact path="/" element={<Main />}/>

    <Route exact path="/about" element={<About />} />

    <Route exact path="/hire" element={<Hire/>} />

    <Route exact path="/support" element={<Support />} />

    <Route path="*" element={<h1>Page not Found</h1>} />

  </Routes>
  <Footer/>
</div>

); }

导出默认应用程序;

/* 网站链接

https://iamniteshpandit.github.io/Chalo-deploy-karte-hain/

存储库链接:-

https://github.com/IAMNITESHPANDIT/Chalo-deploy-karte-hain

你也可以做拉取请求的任何建议,如果那会改进我的代码,那么我肯定会接受:)

*/

导入'./App.css';

从 './component/NavBar.component' 导入 NavBar;

从 './component/main.component' 导入 Main;

从 './component/footer.component' 导入页脚;

从“react-router-dom”导入{路由,路由};

从'./component/NavbarComponent/about.component'导入关于;

从 './component/NavbarComponent/hire.component' 导入 Hire;

从'./component/NavbarComponent/suport.component'导入支持;

function App() { 返回 (

  <Routes>
    /**here path changed path='/' into path="/Chalo-deploy-karte-hain" in-order to application would able to work with github pages  */
   

<Route exact path="/Chalo-deploy-karte-hain" element={}/>

    <Route exact path="/about" element={<About />} />

    <Route exact path="/hire" element={<Hire/>} />

    <Route exact path="/support" element={<Support />} />

    <Route path="*" element={<h1>Page not Found</h1>} />

  </Routes>

  <Footer/>

</div>

); }

导出默认应用程序;

暂无
暂无

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM