在export default 外面 var stompClient = null;
methods
connection() {
// 建立连接对象
this.socket = new SockJS('http://192.168.6.56:8081/endpoint');
stompClient = Stomp.over(this.socket);
//广播(一对多)
stompClient.connect({}, (frame) => {
console.log('Connected:' + frame);
在这里调一对多的接口就可以('/topic/getResponse'),调一对多的接口就不行('/user/39/queue/getResponse')
stompClient.subscribe('/user/39/queue/getResponse',function(response){
console.log(123123123)
console.log(JSON.parse(response.body));
})
}, (err) => {
console.log(err)
});
},
mounted
this.connection()