我的 React 应用程序在 github 页面中没有像代码一样出现

My react app does not seen in github pages like a code

视频看了很多,文档也看了很多,就是做不了这门课。你能帮帮我吗?

首先,我在 github 上有一个 React 应用程序,这里:https://github.com/alper-efe-sahin/portfolio-v2 (它完成了应用程序)

我有 2 个分支,第一个 MASTER 分支和第二个 GH-PAGES 分支。

我使用 npm 运行 build 和 npm 运行 deploy 代码创建了 GH-PAGES。 你也可以在这里看到我的一些包 json 代码:

    "gh-pages": "^3.2.3",
    "deploy": "gh-pages -d build"
  "homepage": "https://github.com/alper-efe-sahin/portfolio-v2",

当我尝试创建 github 页面时,它显示了我的 github 页面,注意它是代码。 (比如显示react文档,不是react代码,不是html css等)

我怎样才能像一个好的网站一样显示我的代码?

您在 package.json

中的 属性 homepage 处设置了错误的值

应该是https://alper-efe-sahin.github.io/portfolio-v2

同时在 scripts 中添加脚本 "predeploy": "npm run build" 和部署,这样当您 运行 npm run deploy 它也会首先使用 npm 构建您的应用程序。

来源:The guide I followed for my cra