如何将 angular 4 webapp 集成到另一个 webapp 中(jsp 样式)



我有一个部署在tomcat 7上的旧Web应用程序,我想用角度4创建一个新部分。为了进行一些测试,我放置了一个带有索引的dist文件夹.html其中<base href="."> Webapps/项目文件夹中,并在现有Web应用程序的html中添加一个iframe,iframe包含一个

<html>
<body>
   <app-root></app-root> 
</body>
</html>

但是任何东西都会显示在 iframe 中。如果我插入代码是只显示代码:

 <html>
<body>
   <app-root></app-root> 
</body>
</html>

有人知道如何冲击它吗?

要使用SystemJS,您可以使用本教程:

带有SystemJS的jsp中的Angular 4

使用 webpack,您应该导入dist文件夹下index.html内的所有 js 和 css,如下所示:

<html>
<head>
<script type="text/javascript" src="../angularWeb/dist/inline.136b795d1580a6687eae.bundle.js"></script>
<script type="text/javascript" src="../angularWeb/dist/polyfills.8eba0ab53b5457105d75.bundle.js"></script>
<script type="text/javascript" src="../angularWeb/dist/vendor.091a5f9daa5d2223e9cf.bundle.js"></script>
<script type="text/javascript" src="../angularWeb/dist/main.b235b84cde360ec37e99.bundle.js"></script>
<link href="../angularWeb/dist/styles.f6578a3761ef80039afc.bundle.css" rel="stylesheet"/>
</head>
<body>
    <app-root></app-root>
</body>
</html>

是 dist/index.html 的复制粘贴。并将角度项目的所有文件放在webapp文件夹下。

最新更新