首页 文章

将AngularJS代码结构化为WAR包

提问于
浏览
0

我想用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>

我怎么能解决这个问题?

1 回答

  • 0

    您不需要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>
    

相关问题