将Angular 7部署到github时获取空白的index.html [英] Getting blank index.html when Angular 7 deploy to github

查看:122
本文介绍了将Angular 7部署到github时获取空白的index.html的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

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

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

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

解决方案

如果部署除主域之外的网站,则需要使用这种命令来构建它.

  • 在您的示例中,我可以看到您正在使用名为/website的子目录url. 因此,运行此命令.

      ng build --prod --output-path docs --base-href /website/
    

  • 构建完成后,请复制docs/index.html并将其命名为docs/404.html.

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

在官方文档中明确提到了它.

角度文档-部署Github页面

I have deployed Angular website using Github pages. Entire process is successful but when I am opening the website its showing blank page. Its loading index.html page but still its blank. Can you please help me solve the issue.

Here is the link https://s530860.github.io/website/

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

解决方案

If you deploy your website other than the main domain, you need to build it with this type of command.

  • In your example I can see you have using sub directory url called /website. So run this command.

      ng build --prod --output-path docs --base-href /website/
    

  • When the build is complete, make a copy of docs/index.html and name it docs/404.html.

  • Then push your docs directory to Github.

It is clearly mentioned in the official docs.

Angular Docs - Deploying Github Pages

这篇关于将Angular 7部署到github时获取空白的index.html的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆