簡體   English   中英

未捕獲的ReferenceError:系統未定義角度4

[英]Uncaught ReferenceError: System is not defined angular 4

我在我的項目中安裝了angular2-recaptcha( https://github.com/xmaestro/angular2-recaptcha )。

我添加了systemjs.config.js

System.config({
  map: {
    'angular2-recaptcha': 'node_modules/angular2-recaptcha'
  },
  packages: {
    app: {
      format: 'register',
      defaultExtension: 'js'
    },
    'angular2-recaptcha': {defaultExtension: 'js', main:'index'}
  }
});

index.html

<script src="systemjs.config.js"></script>
<script>
 System.import('app').catch(function(err){
     console.error(err);
 });
</script>

但我在瀏覽器控制台中收到此錯誤:

  Uncaught ReferenceError: System is not defined
    at localhost/:29
compiler.es5.js:15996 Uncaught Error: Unexpected module 'ReCaptchaModule' declared by the module 'AppModule'. Please add a @Pipe/@Directive/@Component annotation.
    at syntaxError (compiler.es5.js:1690)
    at compiler.es5.js:15430
    at Array.forEach (<anonymous>)
    at CompileMetadataResolver.webpackJsonp.../../../compiler/@angular/compiler.es5.js.CompileMetadataResolver.getNgModuleMetadata (compiler.es5.js:15412)
    at JitCompiler.webpackJsonp.../../../compiler/@angular/compiler.es5.js.JitCompiler._loadModules (compiler.es5.js:26795)
    at JitCompiler.webpackJsonp.../../../compiler/@angular/compiler.es5.js.JitCompiler._compileModuleAndComponents (compiler.es5.js:26768)
    at JitCompiler.webpackJsonp.../../../compiler/@angular/compiler.es5.js.JitCompiler.compileModuleAsync (compiler.es5.js:26697)
    at PlatformRef_.webpackJsonp.../../../core/@angular/core.es5.js.PlatformRef_._bootstrapModuleWithZone (core.es5.js:4536)
    at PlatformRef_.webpackJsonp.../../../core/@angular/core.es5.js.PlatformRef_.bootstrapModule (core.es5.js:4522)
    at Object.../../../../../src/main.ts (main.ts:11)

請幫我! 我的錯誤在哪里?

您需要加載SystemJS庫,而不僅僅是配置:

<script src="systemjs/dist/system.js"></script>   <---------------------
<script src="systemjs.config.js"></script>
<script>
    System.import('app').catch(function(err){ console.error(err); });
</script>

此外,不推薦使用System使用,使用SystemJS ,其中System是全局對象,例如,而不是System.import使用SystemJS.import

暫無
暫無

聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.

 
粵ICP備18138465號  © 2020-2024 STACKOOM.COM