【问题标题】:Angular-cli: how to run the app from index-dev.html instead of index.htmlAngular-cli:如何从 index-dev.html 而不是 index.html 运行应用程序
【发布时间】:2017-10-06 20:17:12
【问题描述】:

我使用angular-cli(版本1.0.2)创建了一个angular项目,但是我需要从index-dev.html而不是index.html运行,并且index-dev.html会和index有相同的内容.html,只是命名文件不同。

不使用 angular-cli,我可以在 bs-config.json 文件中配置 lite-server。但是如何在 angular-cli 项目中进行配置?

【问题讨论】:

    标签: angular angular-cli


    【解决方案1】:

    步骤:

    1. 转到 .angular-cli.json 文件
    2. 在“应用程序”部分下找到属性“索引”
    3. 将此属性的值从“index.html”更改为“index-dev.html”

    【讨论】:

      【解决方案2】:

      更新 angular-cli 文件。

      {
      
        "apps": [
          {
      
            "index": "index-dev.html",
      }
      }
      

      【讨论】:

      • 感谢@Jonnysai,但它不起作用。这是错误Error: Child compilation failed: Entry module not found: Error: Can't resolve 'project-name/src/index-dev.html' in 'project-name':
      • 错误显示 Cli 无法在 src 文件夹中找到 index-dev.html。您的 index-dev.html 是否包含在 src 文件夹中?如果它现在尝试再次运行 ng serve
      • 我的错,我不小心创建了两个index.html并重命名了错误的。
      • 如果我想在index-dev.html后面加上参数,会不会也是一样的情况,比如在.angular-cli.json里改成index-dev.html?debug=true?如果我进行了此更改,则在获取 package.json 时,它会在调试工具网络选项卡中出现 404 错误。
      • 我不知道我们是否可以这样做。但是您可以尝试使用路线。 stackoverflow.com/questions/39858471/…
      猜你喜欢
      • 2020-12-29
      • 1970-01-01
      • 2018-01-03
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 2019-11-18
      • 2017-06-30
      • 1970-01-01
      相关资源
      最近更新 更多