我一直有错误,并且看到了
错误:无法解析DataComponent的所有参数
我不知道如何调试它来自哪里。任何帮助或提示都将不胜感激。
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]