谷歌的reCAPTCHA - 缺少systemjs

时间:2017-07-22 05:38:46

标签: angular typescript recaptcha

我正试图在this tutorial之后在Angular中实施Google的reCAPTCHA 我无法在Angular CLI项目中找到systemjs.config.js。如何解决这个问题?

1 个答案:

答案 0 :(得分:0)

您需要创建一个“systemjs.config.js”文件并从index.html加载它,就像常规脚本一样

<script src="node_modules/systemjs/dist/system.src.js"></script>
 <script src="systemjs.config.js"></script>

(!!!重要您应该 system.src.js 之前 systemjs.config.js 文件

这是SystemJS.config.js文件

的示例
/**
 * System configuration for Angular 2 samples
 * Adjust as necessary for your application needs.
 */
(function(global) {
  // map tells the System loader where to look for things
  var map = {
    'app':                        'app', // 'dist',
    '@angular':                   'node_modules/@angular',
    'angular2-in-memory-web-api': 'node_modules/angular2-in-memory-web-api',
    'rxjs':                       'node_modules/rxjs'
  };
  // packages tells the System loader how to load when no filename and/or no extension
  var packages = {
    'app':                        { main: 'main.js',  defaultExtension: 'js' },
    'rxjs':                       { defaultExtension: 'js' },
    'angular2-in-memory-web-api': { main: 'index.js', defaultExtension: 'js' },
  };
  var ngPackageNames = [
    'common',
    'compiler',
    'core',
    'forms',
    'http',
    'platform-browser',
    'platform-browser-dynamic',
    'router',
    'router-deprecated',
    'upgrade',
  ];
  // Individual files (~300 requests):
  function packIndex(pkgName) {
    packages['@angular/'+pkgName] = { main: 'index.js', defaultExtension: 'js' };
  }
  // Bundled (~40 requests):
  function packUmd(pkgName) {
    packages['@angular/'+pkgName] = { main: 'bundles/' + pkgName + '.umd.js', defaultExtension: 'js' };
  }
  // Most environments should use UMD; some (Karma) need the individual index files
  var setPackageConfig = System.packageWithIndex ? packIndex : packUmd;
  // Add package entries for angular packages
  ngPackageNames.forEach(setPackageConfig);
  var config = {
    map: map,
    packages: packages
  };
  System.config(config);
})(this);

请参阅this tutorial for more information