javascript - 将 AngularJS 代码构造成 WAR 包

标签 javascript html angularjs tomcat war

我想用 AngularJS 代码创建 WAR 包:

enter image description here

我以这种方式从资源目录导入 .js 文件:

<script src="resources/vendor/es6-shim/es6-shim.js"></script>

但我不知道如何从 Javascript 代码导入 .js 文件:

<script>
      System.import('resources/system-config.js').then(function () {
        System.import('main');
      }).catch(console.error.bind(console));
    </script>

我该如何解决这个问题?

最佳答案

您不需要将 JS 放在 WEB-INF 目录中,因为浏览器将无法请求该目录中的文件(除非您在服务器上有一些东西可以拦截对“/resources”的请求,并且从该目录读取文件)。看起来您在“/public”目录中也有 JS 代码,因此您的 JS 文件应该从那里加载。

<script src="public/vendor/es6-shim/es6-shim.js"></script>

<script>
  System.import('public/system-config.js').then(function () {
    System.import('main');
  }).catch(console.error.bind(console));
</script>

关于javascript - 将 AngularJS 代码构造成 WAR 包,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/38935762/

相关文章:

javascript - 通过 'for in'在javascript中获取对象的键和值

javascript - 最常见的 HTML 模板语言

php - 只有当它包含关键字时,才使用 CSS 隐藏具有特定类名的某些 tr

javascript - V-model 和 TinyMCE 不能一起工作

javascript - 使用ajax刷新页面的一部分 - 不起作用

javascript - onclick 事件仅适用于按钮,不适用于与按钮一起使用的字形

javascript - 使用 jQuery 在 textarea 中向下滚动

javascript - 如何在 AngularJS 中创建工厂?

javascript - 使用 ngAudio 时出现 AngularJS 错误

angularjs - 需要 AngularJS 输入表单中的 select 用法示例