我在我的組件中使用System
。System.import使用導致我的控制檯出現多個錯誤
export class LoginComponent {
constructor() {
System.import('app/login/login.js');
}
}
文件加載罰款,但打字稿compiller說
Error:(10, 9) TS2304: Cannot find name 'System'.
我的瀏覽器控制檯說
EXCEPTION: Error: Uncaught (in promise): Error: Error: http://localhost:3000/app/login/login.js detected as register but didn't execute.
at ZoneDelegate.invoke (http://localhost:3000/node_modules/angular2/bundles/angular2-polyfills.js:332:29)
at Object.NgZoneImpl.inner.inner.fork.onInvoke (http://localhost:3000/node_modules/angular2/bundles/angular2.dev.js:2111:31)
at ZoneDelegate.invoke (http://localhost:3000/node_modules/angular2/bundles/angular2-polyfills.js:331:35)
at Zone.run (http://localhost:3000/node_modules/angular2/bundles/angular2-polyfills.js:227:44)
Error loading http://localhost:3000/app/login/login.js
Error: Uncaught (in promise): Error: Error: http://localhost:3000/app/login/login.js detected as register but didn't execute.(…)
我該如何解決呢?
爲什麼在TypeScript中使用'System.import'而不是ES6導入語法?什麼是'login.js'?在哪裏找到了「LoginComponent」文件? – rgvassar
@rgvassar login.js是一個用動畫支持我的頁面的腳本。如何使用ES6語法導入我的.js文件? – Viktor