【问题标题】:Getting blank index.html when Angular 7 deploy to githubAngular 7 部署到 github 时获取空白 index.html
【发布时间】:2019-04-26 23:11:47
【问题描述】:

我已经使用 Github 页面部署了 Angular 网站。整个过程是成功的,但是当我打开网站时,它显示空白页面。它正在加载 index.html 页面,但仍然是空白的。你能帮我解决这个问题吗?

这里是链接https://s530860.github.io/website/

https://s530860.github.io/website/

【问题讨论】:

  • 你是用ng build --prod命令构建的吗?

标签: angular github-pages


【解决方案1】:

如果您在主域之外部署您的网站,则需要使用这种类型的命令来构建它。

  • 在您的示例中,我可以看到您使用了名为 /website 的子目录 url。 所以运行这个命令。

      ng build --prod --output-path docs --base-href /website/
    
  • 构建完成后,复制 docs/index.html 并将其命名为 docs/404.html。

  • 然后将您的 docs 目录推送到 Github。

官方文档中明确提到了。

Angular Docs - Deploying Github Pages

【讨论】:

    【解决方案2】:

    你还需要:

    --deploy-url /website/
    

    【讨论】:

      猜你喜欢
      • 2021-02-14
      • 2020-10-13
      • 1970-01-01
      • 2021-01-14
      • 1970-01-01
      • 1970-01-01
      • 2021-12-22
      • 2022-10-23
      • 1970-01-01
      相关资源
      最近更新 更多