【发布时间】:2016-10-07 09:10:07
【问题描述】:
我一直有错误,并且已经看到了
错误:无法解析 DataComponent 的所有参数
我不知道如何调试它来自哪里。任何帮助或提示将不胜感激。
数据组件.ts
import { Component, OnInit, Inject } from '@angular/core';
import { Message, Client, Stomp } from 'stompjs';
import * as SockJS from 'sockjs-client';
@Component({
selector: 'data',
template: `
<div id="raw">
<h2>Messages</h2>
<p>{{message}}</p>
</div>
`,
})
export class DataComponent implements OnInit, OnDestroy {
constructor(private client : Client) { }
mq_username = "guest";
mq_password = "guest";
mq_vhost = "/";
mq_url = 'http://localhost:15674/stomp';
mq_queue = "/exchange/helloworld";
public message: string;
/** Callback on_connect to queue */
public on_connect = () => {
console.log('client', this.client);
this.client.subscribe(this.mq_queue, function(message: Message) {
this.message = message.body;
})
}
public on_connect_error(){
console.log('connection failed');
}
ngOnInit() {
this.client = Stomp.client(this.mq_url);
this.client.connect(
this.mq_username,
this.mq_password,
this.on_connect,
this.on_connect_error,
this.mq_vhost
)
}
}
在 tsconfig.ts 选项中,emitDecoratorMetadata 和 experimentalDecorators 都设置为 true。
systemjs.config 中的库以这种方式包含:
System.config({
paths: {
'npm:': 'node_modules/'
},
map: {
app: 'dist',
// angular bundles
[ANGULAR BUNDLES HERE]
// other libraries
'rxjs': 'npm:rxjs',
'sockjs-client': 'lib/sock-js/sockjs.min.js',
'stompjs': 'node_modules/stompjs/lib/stomp.min.js',
},
[etc]
【问题讨论】: