簡體   English   中英

當我將 React 應用程序部署到 github 個頁面時,它無法正確呈現

[英]React app didn't render correctly when I deployed it to github pages

我嘗試將我的 React 應用程序部署到 github 個頁面,但它似乎無法正常工作。 當我試圖通過鏈接訪問它時,我得到了一個空白頁面。 有人知道解決方案嗎? 謝謝您的幫助!

我的代碼是這樣的: package.json

  "homepage": "https://yunxiuqiu1115.github.io/food-ordering-site",
  "scripts": {
    "start": "PORT=3006 react-scripts start",
    "build": "react-scripts build",
    "test": "react-scripts test",
    "eject": "react-scripts eject",
    "predeploy": "npm run build",
    "deploy": "gh-pages -d build"
  },

我運行了npm run deploy並獲得了成功的結果。

一切都在本地運行良好,但在 github 頁面中不起作用。 希望任何人都可以提供幫助! 謝謝!

我們需要安裝 GitHub Pages package 作為開發依賴

cd **
npm install gh-pages --save-dev

將屬性添加到 package.json 文件。

按照此了解更多詳細信息https://dev.to/yuribenjamin/how-to-deploy-react-app-in-github-pages-2a1f

暫無
暫無

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

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