我使用以下技术设置了一个基本的 Angular 2 应用程序: angular.io/docs/ts/latest/quickstart.html
我使用以下技术将 Kendo UI 添加到我的应用程序中: www.telerik.com/kendo-angular-ui/getting-started (使用快速启动方法)
Kendo UI 按钮按预期显示和工作。所以现在我想使用这种技术添加 Kendo UI 图表: www.telerik.com/kendo-angular-ui/components/charts/#installation
这导致我的 Chrome 浏览器(版本 54.0.2840.71 m)的控制台窗口出现以下错误:
//localhost:3002/@progress/kendo-angular-charts 404(未找到)
错误:(SystemJS) XHR 错误 (404 Not Found) loading //localhost:3002/@progress/kendo-angular-charts(...)
我的图表组件是否需要 system.config.js 中的引用/定义?不确定,因为 Kendo UI 安装文档没有提到它。我确实看到了关于这个按钮的一些东西,所以......让我们添加它。
(function (global) {
System.config({
paths: {
// paths serve as alias
'npm:': 'node_modules/'
},
// map tells the System loader where to look for things
map: {
'@progress/kendo-angular-buttons': 'npm:@progress/kendo-angular-buttons',
'@progress/kendo-angular-charts': 'npm:@progress/kendo-angular-charts',
// 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',
'@angular/upgrade': 'npm:@angular/upgrade/bundles/upgrade.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: {
'npm:@progress/kendo-angular-buttons': {
main: './dist/npm/js/main.js',
defaultExtension: 'js'
},
'npm:@progress/kendo-angular-charts': {
main: './dist/npm/js/main.js',
defaultExtension: 'js'
},
app: {
main: './main.js',
defaultExtension: 'js'
},
rxjs: {
defaultExtension: 'js'
}
}
});
})(this);
现在我在控制台中收到以下错误:
GET //localhost:3002/@progress/kendo-angular-popup 404(未找到) GET //localhost:3002/@progress/kendo-angular-resize-sensor 404(未找到)错误:(SystemJS)XHR错误( 404 Not Found) loading //localhost:3002/@progress/kendo-angular-popup(...) GET //localhost:3002/@progress/kendo-charts 404 (Not Found) GET //localhost:3002/@progress/ kendo-angular-intl 404 (未找到) GET //localhost:3002/@progress/kendo-angular-popup 404 (未找到) GET //localhost:3002/@progress/kendo-angular-resize-sensor 404 (未成立)
所以现在我想我需要将更多这些引用/定义添加到 system.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: {
'@progress/kendo-angular-buttons': 'npm:@progress/kendo-angular-buttons',
'@progress/kendo-angular-charts': 'npm:@progress/kendo-angular-charts',
'@progress/kendo-charts': 'npm:@progress/kendo-charts',
'@progress/kendo-angular-popup': 'npm:@progress/kendo-angular-popup',
'@progress/kendo-angular-resize-sensor': 'npm:@progress/kendo-angular-resize-sensor',
'@progress/kendo-angular-intl': 'npm:@progress/kendo-angular-intl',
'@progress/kendo-popup-common': 'npm:@progress/kendo-popup-common',
'@progress/kendo-drawing': 'npm:@progress/kendo-drawing',
'@telerik/kendo-intl': 'npm:@telerik/kendo-intl',
'@telerik/kendo-draggable': 'npm:@telerik/kendo-draggable',
// 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',
'@angular/upgrade': 'npm:@angular/upgrade/bundles/upgrade.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: {
'npm:@progress/kendo-angular-buttons': {
main: './dist/npm/js/main.js',
defaultExtension: 'js'
},
'npm:@progress/kendo-angular-charts': {
main: './dist/npm/js/main.js',
defaultExtension: 'js'
},
'npm:@progress/kendo-angular-resize-sensor': {
main: './dist/npm/js/main.js',
defaultExtension: 'js'
},
'npm:@progress/kendo-charts': {
main: './dist/npm/js/main.js',
defaultExtension: 'js'
},
'@progress/kendo-angular-popup': {
defaultExtension: 'js',
main: "./dist/npm/js/main.js"
},
'@progress/kendo-angular-intl': {
defaultExtension: 'js',
main: "./dist/npm/js/main.js"
},
'@progress/kendo-popup-common': {
defaultExtension: 'js',
main: "./dist/npm/js/main.js"
},
'@progress/kendo-drawing': {
defaultExtension: 'js',
main: "./dist/npm/js/main.js"
},
'@telerik/kendo-intl': {
defaultExtension: 'js',
main: "./dist/npm/js/main.js"
},
'@telerik/kendo-draggable': {
defaultExtension: 'js',
main: "./dist/npm/js/main.js"
},
app: {
main: './main.js',
defaultExtension: 'js'
},
rxjs: {
defaultExtension: 'js'
}
}
});
})(this);
现在我收到以下错误:
GET //localhost:3002/chroma-js 404 (Not Found) Error: (SystemJS) XHR error (404 Not Found) loading //localhost:3002/chroma-js(...) GET //localhost:3002/chroma-js 404(未找到)
不知道现在该怎么办。我会尽可能多地发布关于我的环境的信息。任何帮助是极大的赞赏。
节点:版本 v.2.2 nmp:版本 3.9.5 剑道图表:['0.4.0','0.4.1','0.5.0','0.5.1','0.5.2','0.5.3 ','0.6.0','0.7.0','0.7.1','0.7.2','0.7.3','0.7.4','0.7.5','0.8.0', '0.8.1']
应用程序模块.ts
import { BrowserModule } from '@angular/platform-browser';
import { NgModule } from '@angular/core';
import { HttpModule } from '@angular/http';
import { ButtonsModule } from '@progress/kendo-angular-buttons';
import { ChartsModule } from '@progress/kendo-angular-charts';
import { AppComponent } from './app.component';
@NgModule({
declarations: [
AppComponent
],
imports: [
BrowserModule,
HttpModule,
ButtonsModule,
ChartsModule
],
providers: [],
bootstrap: [AppComponent]
})
export class AppModule { }
app.component.ts
import { Component } from '@angular/core';
@Component({
selector: 'my-app',
styleUrls: [
// load the default theme
'../node_modules/@telerik/kendo-theme-default/dist/all.css'
],
template: `
My First Kendo UI Angular 2 App
<button
kendoButton
(click)="onButtonClick()"
[primary]="true">
My Kendo UI Button
</button>
`
})
export class AppComponent {
onButtonClick() {
alert('Hello from Kendo UI!');
}
}
包.json
{
"name": "angular-quickstart",
"version": "1.0.0",
"scripts": {
"start": "tsc && concurrently \"tsc -w\" \"lite-server\" ",
"lite": "lite-server",
"tsc": "tsc",
"tsc:w": "tsc -w"
},
"licenses": [
{
"type": "MIT",
"url": "https://github.com/angular/angular.io/blob/master/LICENSE"
}
],
"dependencies": {
"@angular/common": "~2.1.1",
"@angular/compiler": "~2.1.1",
"@angular/core": "~2.1.1",
"@angular/forms": "~2.1.1",
"@angular/http": "~2.1.1",
"@angular/platform-browser": "~2.1.1",
"@angular/platform-browser-dynamic": "~2.1.1",
"@angular/router": "~3.1.1",
"@angular/upgrade": "~2.1.1",
"@progress/kendo-angular-buttons": "^0.13.2",
"@progress/kendo-angular-charts": "^0.8.1",
"@telerik/kendo-theme-default": "^1.29.0",
"angular-in-memory-web-api": "~0.1.13",
"core-js": "^2.4.1",
"reflect-metadata": "^0.1.8",
"rxjs": "5.0.0-beta.12",
"systemjs": "0.19.39",
"zone.js": "^0.6.25"
},
"devDependencies": {
"@types/core-js": "^0.9.34",
"@types/node": "^6.0.45",
"concurrently": "^3.0.0",
"lite-server": "^2.2.2",
"typescript": "^2.0.3"
}
}
索引.html
<html>
<head>
<title>Angular QuickStart</title>
<meta charset="UTF-8">
<meta name="viewport" content="width=device-width, initial-scale=1">
<link rel="stylesheet" href="http://www.telerik.com/kendo-angular-ui/npm/node_modules//@telerik/kendo-theme-default/dist/all.css" />
<link rel="stylesheet" href="styles.css">
<!-- 1. Load libraries -->
<!-- Polyfill(s) for older browsers -->
<script src="node_modules/core-js/client/shim.min.js"></script>
<script src="node_modules/zone.js/dist/zone.js"></script>
<script src="node_modules/reflect-metadata/Reflect.js"></script>
<script src="node_modules/systemjs/dist/system.src.js"></script>
<!-- 2. Configure SystemJS -->
<script src="systemjs.config.js"></script>
<script>
System.import('app').catch(function(err){ console.error(err); });
</script>
</head>
<!-- 3. Display the application -->
<body>
<my-app>Loading...</my-app>
</body>
</html>