//初始化websocket
initWebsocket(wbUrl){
this.websocket = new WebSocket(wbUrl);
this.websocket.onopen = this.websocketOpen;
this.websocket.onmessage = this.websocketMessage;
this.websocket.onerror = this.websocketError;
},
//发送请求
websocketOpen(){
console.log('websocketOK');
this.websocket.send(this.$route.query.id);
},
//websocket链接成功
websocketMessage(e){
console.log(e)
},
//建立
created(){
this.initWebsocket('你的websocketUrl');
},
//销毁
destroyed(){
this.websocket.close();
}