【问题标题】:Angular Library build with --base-href使用 --base-href 构建 Angular 库
【发布时间】:2020-08-09 20:22:32
【问题描述】:

我有几个自定义 Angular 库,它们将用于 Angular 可运行应用程序。这个可运行的应用程序是使用ng build --deploy-url="dist/" --base-href="appContextPath" 构建的,并使用 maven 插件复制到 war 文件中。

当我使用http://localhost:8080/appContextPath 运行应用程序时,作为可运行应用程序一部分的资产正在加载,但库资产未加载。

我的观察:

1) 开发者工具中的应用资产加载url:

http://localhost:8080/appContextPath/assets/images/search.png

2) 开发者工具中的库资源加载url:

http://localhost:8080/assets/images/xyz.png base-href。

【问题讨论】:

    标签: maven npm angular8 npm-scripts angular-library


    【解决方案1】:

    来自angular's documentation

    The <base href> path should end with a "/", as browsers ignore characters in the path 
    that follow the right-most "/".
    

    你的情况,试试--base-href="/appContextPath/"

    【讨论】:

      猜你喜欢
      • 2018-03-21
      • 2016-12-07
      • 2018-06-01
      • 2020-06-28
      • 1970-01-01
      • 2021-11-19
      • 2022-01-13
      • 2017-07-06
      • 2017-04-08
      相关资源
      最近更新 更多