我想用 AngularJS 代码创建 WAR 包:
我以这种方式从资源目录导入 .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/