gpt4 book ai didi

javascript - Angular2 + ag-Grid 无法加载 ag-grid-ng2/main.js (404 Not Found)

转载 作者:行者123 更新时间:2023-12-02 14:10:40 25 4
gpt4 key购买 nike

我正在尝试将 ag-Grid 与 Angular2 集成,但遇到以下错误:

zone.js:101 GET http://localhost:4200/node_modules/ag-grid-ng2/main.js 404 (Not Found)

我使用以下方式导入第三方组件:

import {AgGridNg2} from 'ag-grid-ng2/main';
...
directives: [AgGridNg2]

这是我的system-config.ts文件:

"use strict";

// SystemJS configuration file, see links for more information
// https://github.com/systemjs/systemjs
// https://github.com/systemjs/systemjs/blob/master/docs/config-api.md

/***********************************************************************************************
* User Configuration.
**********************************************************************************************/
/** Map relative paths to URLs. */
const map: any = {
// ag libraries
'ag-grid-ng2': 'node_modules/ag-grid-ng2',
'ag-grid': 'node_modules/ag-grid',
'ag-grid-enterprise' : 'node_modules/ag-grid-enterprise'
};

/** User packages configuration. */
const packages: any = {
'ag-grid-ng2': {
defaultExtension: "js"
},
'ag-grid': {
defaultExtension: "js"
},
'ag-grid-enterprise': {
defaultExtension: "js"
}
};

////////////////////////////////////////////////////////////////////////////////////////////////
/***********************************************************************************************
* Everything underneath this line is managed by the CLI.
**********************************************************************************************/
const barrels: string[] = [
// Angular specific barrels.
'@angular/core',
'@angular/common',
'@angular/compiler',
'@angular/forms',
'@angular/http',
'@angular/router',
'@angular/platform-browser',
'@angular/platform-browser-dynamic',

// Thirdparty barrels.
'rxjs',

// App specific barrels.
'app',
'app/shared',
'app/full-width-renderer',
/** @cli-barrel */
];

const cliSystemConfigPackages: any = {};
barrels.forEach((barrelName: string) => {
cliSystemConfigPackages[barrelName] = { main: 'index' };
});

/** Type declaration for ambient System. */
declare var System: any;

// Apply the CLI SystemJS configuration.
System.config({
map: {
'@angular': 'vendor/@angular',
'rxjs': 'vendor/rxjs',
'main': 'main.js'
},
packages: cliSystemConfigPackages
});

// Apply the user's configuration.
System.config({ map, packages });

我可以在 /node_modules/ag-grid-ng2 文件夹下看到依赖项:

非常感谢任何帮助。

最佳答案

我没有使用过企业网格,但是为了在 Angular 2 中使用 ag-grid,您需要将其包含在 System.config 的 map 部分中:

'ag-grid': 'node_modules/ag-grid',
'ag-grid-ng2': 'node_modules/ag-grid-ng2'

还要确保您的 node_modules 包中有这些模块,否则请确保将这些描述包含在您的 package.json 中并首先运行“npm install”。

关于javascript - Angular2 + ag-Grid 无法加载 ag-grid-ng2/main.js (404 Not Found),我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/39619828/

25 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com