2016-08-13 86 views
0

我想與AngularJS代碼創建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> 

我該如何解決這個問題?

回答

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> 
+0

它不工作。我得到ReferenceError:系統沒有定義 \t System.import('public/system-config.js')。then(function(){ –