簡體   English   中英

知道為什么我的 Github 頁面網站沒有顯示嗎? ReactJS

[英]Any idea why my Github Pages site isn't showing? ReactJS

這是我的 GH 頁面的鏈接

https://filipdimko11.github.io/crypto-tracker/

在本地運行時,項目會呈現所有內容。 但是,在 GH 頁面上托管它之后,該網站不會呈現任何內容(控制台中也沒有錯誤)。

我嘗試進行空提交,將其視為 StackOverflow 上的另一種解決方案,但這並沒有解決問題。 使用 ReactJS,謝謝。

問題是因為在您的index.html文件中,您引用了/static/js/main.2227a53b.js等資產,這在您在本地運行時是有意義的。

但是當你部署到github頁時,目錄結構就不同了。 為了使其正常工作,您需要在路由前加上crypto-tracker/例如:

<!DOCTYPE html>
<html lang="en">
  <head>
    <meta charset="utf-8" />
    <meta name="viewport" content="width=device-width,initial-scale=1" />
    <meta name="theme-color" content="#000000" />
    <link rel="preconnect" href="https://fonts.googleapis.com" />
    <link rel="preconnect" href="https://fonts.gstatic.com" crossorigin />
    <link
      href="https://fonts.googleapis.com/css2?family=Roboto&display=swap"
      rel="stylesheet"
    />
    <meta name="description" content="Your best crypto tracker!" />
    <link rel="manifest" href="/manifest.json" />
    <title>Crypto Tracker</title>
    <script defer="defer" src="crypto-tracker/static/js/main.2227a53b.js"></script>
    <link href="crypto-tracker/static/css/main.f53fb378.css" rel="stylesheet" />
  </head>
  <body>
    <noscript>You need to enable JavaScript to run this app.</noscript>
    <div id="root"></div>
  </body>
</html>

根據您使用的構建工具,這可能是可配置的。

暫無
暫無

聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.

 
粵ICP備18138465號  © 2020-2024 STACKOOM.COM