在vue项目中使用websocket时遇到问题

时间:2019-10-07 11:08:19

标签: vue.js websocket

使用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)
                    });
                });
            },

感谢您的帮助

0 个答案:

没有答案