在使用websocket的时候报错
Uncaught TypeError: Cannot read property 'subscribe' of undefined
代码很简单
init() {
let socket = new SockJS('http://127.0.0.1:8080/gs-guide-websocket');
this.stompClient = Stomp.over(socket);
this.stompClient.connect({}, function (frame) {
this.stompClient.subscribe('/topic/greetings', function (msg) {
console.log(msg.body)
});
});
},
不知道为啥报错
请教各位大哥,小弟谢过啦