gpt4 book ai didi

javascript - Angular 4 + ngx-数据表 : @swimlane/ngx-datatable 404 (Not Found)

转载 作者:行者123 更新时间:2023-12-03 04:01:53 31 4
gpt4 key购买 nike

我对 Angular 还很陌生。我运行这个来开始我的项目:git 克隆 https://github.com/angular/quickstart appName

我将其更新到 Angular 4,一切都应该很顺利。以下是运行 ng -v 的输出:

@angular/cli: 1.1.3
node: 6.11.0
os: darwin x64
@angular/common: 4.0.3
@angular/compiler: 4.0.3
@angular/core: 4.0.3
@angular/forms: 4.0.3
@angular/http: 4.0.3
@angular/platform-browser: 4.0.3
@angular/platform-browser-dynamic: 4.0.3
@angular/router: 4.0.3
@angular/cli: 1.1.3

我需要一个高度可配置的表格模块ngx-datatable是一个不错的选择。我按照这些页面上的说明进行操作:

https://swimlane.gitbooks.io/ngx-datatable/introduction/installing.html https://swimlane.gitbooks.io/ngx-datatable/introduction/getting-started.html

我可以运行 npm start 并加载应用程序,但我的浏览器遇到错误,导致应用程序中断:

GET http://localhost:3006/@swimlane/ngx-datatable 404(未找到)

enter image description here

这是我的app.module.ts:

import { NgModule, CUSTOM_ELEMENTS_SCHEMA }      from '@angular/core';
import { BrowserModule } from '@angular/platform-browser';
import { HttpModule } from '@angular/http' ;
import { NgxDatatableModule } from '@swimlane/ngx-datatable';

import { AppComponent } from './app.component';

@NgModule({
imports: [ BrowserModule, HttpModule, NgxDatatableModule ],
declarations: [ AppComponent ],
bootstrap: [ AppComponent ],
schemas: [ CUSTOM_ELEMENTS_SCHEMA ]
})
export class AppModule { }

我的package.json的一部分:

"dependencies": {
"@angular/common": "~4.0.0",
"@angular/compiler": "~4.0.0",
"@angular/core": "~4.0.0",
"@angular/forms": "~4.0.0",
"@angular/http": "~4.0.0",
"@angular/platform-browser": "~4.0.0",
"@angular/platform-browser-dynamic": "~4.0.0",
"@angular/router": "~4.0.0",
"angular-in-memory-web-api": "~0.3.0",
"systemjs": "0.19.40",
"core-js": "^2.4.1",
"rxjs": "5.0.1",
"zone.js": "^0.8.4"
},
"devDependencies": {
"@angular/cli": "^1.1.3",
"@types/jasmine": "2.5.36",
"@types/node": "^6.0.46",
"canonical-path": "0.0.2",
"concurrently": "^3.2.0",
"jasmine-core": "~2.4.1",
"karma": "^1.3.0",
"karma-chrome-launcher": "^2.0.0",
"karma-cli": "^1.0.1",
"karma-jasmine": "^1.0.2",
"karma-jasmine-html-reporter": "^0.2.2",
"lite-server": "^2.2.2",
"lodash": "^4.16.4",
"protractor": "~4.0.14",
"rimraf": "^2.5.4",
"tslint": "^3.15.1",
"typescript": "^2.2.0"
}

我的systemjs.config.js:

(function (global) {
System.config({
paths: {
// paths serve as alias
'npm:': 'node_modules/'
},
// map tells the System loader where to look for things
map: {
// our app is within the app folder
'app': 'app',

// angular bundles
'@angular/core': 'npm:@angular/core/bundles/core.umd.js',
'@angular/common': 'npm:@angular/common/bundles/common.umd.js',
'@angular/compiler': 'npm:@angular/compiler/bundles/compiler.umd.js',
'@angular/platform-browser': 'npm:@angular/platform-browser/bundles/platform-browser.umd.js',
'@angular/platform-browser-dynamic': 'npm:@angular/platform-browser-dynamic/bundles/platform-browser-dynamic.umd.js',
'@angular/http': 'npm:@angular/http/bundles/http.umd.js',
'@angular/router': 'npm:@angular/router/bundles/router.umd.js',
'@angular/forms': 'npm:@angular/forms/bundles/forms.umd.js',

// other libraries
'rxjs': 'npm:rxjs',
'angular-in-memory-web-api': 'npm:angular-in-memory-web-api/bundles/in-memory-web-api.umd.js'
},
// packages tells the System loader how to load when no filename and/or no extension
packages: {
app: {
defaultExtension: 'js',
meta: {
'./*.js': {
loader: 'systemjs-angular-loader.js'
}
}
},
rxjs: {
defaultExtension: 'js'
}
}
});
})(this);

我花了一整天的时间来解决这个问题,但我还是在同一个地方。我的设置有什么问题吗?

最佳答案

将以下行添加到您的 system.config.js > map

'@swimlane/ngx-datatable': 'npm:@swimlane/ngx-datatable/release/index.js',

关于javascript - Angular 4 + ngx-数据表 : @swimlane/ngx-datatable 404 (Not Found),我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/44687585/

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