0
我正在嘗試在角度上實現谷歌的reCAPTCHA this tutorial
我在Angular CLI項目中找不到systemjs.config.js。如何解決這個問題?谷歌的reCAPTCHA - systemjs丟失
我正在嘗試在角度上實現谷歌的reCAPTCHA this tutorial
我在Angular CLI項目中找不到systemjs.config.js。如何解決這個問題?谷歌的reCAPTCHA - systemjs丟失
你需要創建一個 「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);
(您需要創建一個「systemjs.config.js」文件)哪個文件夾? –
在任何你想要的地方,但需要在Index.html中加載它,通常的做法是在index.html中添加後在項目的根目錄 – insomniac
中創建它。我得到了這個錯誤的GET http:// localhost: 4200/node_modules/systemjs/dist/system.src.js systemjs.config.js:1 Uncaught ReferenceError:系統未定義 at systemjs.config.js:1 –