如何在另一个 Angular 应用程序(单页应用程序)中加载自定义元素?

问题描述 投票:0回答:0

我的 shell 应用程序的 index.html 文件有一个名为 overview-cards-element 的自定义元素,我在脚本标签中给出了它。 http://localhost:8082/mfe1.js(编译后的js文件)。当我提供我的 shell 应用程序(ng 服务)时,我无法在浏览器上查看自定义元素。我只能从 shell 应用程序中看到页眉和页脚。 the header and footer from shell app (footer not shown in image) 另一方面,当我从静态 index.html 文件运行时,我可以在浏览器上看到自定义元素。 custom element from static index.html file

如何在另一个单页角度应用程序(此处称为 shell 应用程序)中加载自定义元素(微前端应用程序)?我是自定义元素领域的新手。目的是在单个页面角度应用程序上加载许多微前端。我知道 webpack 模块联合是一种方式,但想知道将多个 mfe 加载到单个页面角度应用程序的其他方式。 提前谢谢你

我在 https://medium.com/swlh/build-micro-frontends-using-angular-elements-the-beginners-guide-75ffeae61b58 和 github https 之后创建了一个自定义元素 overview-cards-element ://github.com/funOfheuristic/micro-fe 下面是代码 app.component.js.

这是单页角度应用程序的代码- index.html

angular custom-element micro-frontend
© www.soinside.com 2019 - 2024. All rights reserved.