添加链接
link之家
链接快照平台
  • 输入网页链接,自动生成快照
  • 标签化管理网页链接

在做了一些谷歌搜索后,我了解到问题的发生是因为 angular 8 cli 无法将 type 属性添加到 --- 中的 index.html script 标记。当我手动添加类型时,一切正常。任何人都可以帮助我理解为什么会发生这种情况,以及除了手动编辑之外的可能解决问题的方法。

生成 index.html

 <!doctype html>
<html lang="en">
  <meta charset="utf-8">
  <title>My Application</title>
  <base href="/">
  <meta name="viewport" content="width=device-width, initial-scale=1">
  <i class="fas fa-chart-area"></i>
  <link rel="icon" type="image/x-icon" href="favicon.ico">
</head>
<body style="margin: 0;">
  <app-root></app-root>
<script src="runtime-es2015.js" type="module"></script><script src="runtime-es5.js" nomodule defer></script><script src="polyfills-es5.js" nomodule defer></script><script src="polyfills-es2015.js" type="module"></script><script src="styles-es2015.js" type="module"></script><script src="styles-es5.js" nomodule defer></script><script src="scripts.js" defer></script><script src="vendor-es2015.js" type="module"></script><script src="vendor-es5.js" nomodule defer></script><script src="main-es2015.js" type="module"></script><script src="main-es5.js" nomodule defer></script></body>
</html>

因此,总结所有有效的方法,如下所示:

  • type 属性在 HTML5 中不再是强制性的,因此 Angular cli 不再将其添加为属性。在嵌入式 tomcat 中,资产被复制到 ROOT 完美地工作,当我部署在外部 tomcat 中时,我将资产保存在 webapps 的文件夹下,这意味着我必须修改 baseHref 字段(在使用命令构建期间或手动构建之后)反映相同。以下作品:
  • 将资产保存在 webapps 中的 ROOT 文件夹下(一切正常,因为 js 文件现在位于根目录 / 下)。
  • 将文件保存在文件夹下,例如 MyApp 并在 --- baseHref index.html
  • 相关 链接

    原文由 Ananthapadmanabhan 发布,翻译遵循 CC BY-SA 4.0 许可协议

    回复
    阅读 122
    1 个回答