【问题标题】:Angular 5 app deployed to firebase won't load components部署到 Firebase 的 Angular 5 应用程序不会加载组件
【发布时间】:2018-06-05 14:01:29
【问题描述】:

我能够使用 firebase initfirebase deploy 将 Angular 5 应用部署到 Firebase。

默认情况下,主页是来自public 目录的index.html

我将firebase.json从:

{
  "hosting": {
    "public": "public",

到:

{
  "hosting": {
    "public": "src",

这样我的index.html 就会显示出来。

它显示了,但里面的组件没有加载。我被一个空页面困住了,<app-root></app-root> 标签内部是空的。

如何在我这边配置 firebase 以便它像在我的本地主机上一样工作?

【问题讨论】:

  • 我的眼镜有问题还是这些代码完全一样?
  • 能否进一步详细说明您的问题?
  • 我的错,这是一个复制粘贴错误
  • 但 angular public 是 'dist'
  • 但是 dist 是用于生产的。我不能将 firebase 用于开发版本吗?

标签: angular firebase angular5 firebase-hosting


【解决方案1】:

您的项目文件夹,用于指示 Angular CLI 在 dist 文件夹中为您的应用构建生产就绪的资产集:

ng build --prod
npm install -g firebase-tools
firebase login
firebase init

公共目录:输入 dist,因为这是您的生产就绪 Angular 应用资产所在的位置。

配置为单页应用程序:大多数情况下,您会为这个应用程序说 yes (y)。 覆盖 index.html:No.

src

【讨论】:

    猜你喜欢
    • 2018-06-16
    • 2014-10-29
    • 2018-07-05
    • 1970-01-01
    • 2018-02-26
    • 2019-04-20
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    相关资源
    最近更新 更多