使用websocket时出现错误,“未捕获的TypeError:无法读取未定义的属性'subscribe'”
enter image description here
我的代码是
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)
});
});
},
感谢您的帮助