从js那过来的,参考:https://blog.csdn.net/bbs11007/article/details/109491329,
举一反三使用VUE的方式,url地址写在一个通用main方法里面了,略。
created() {
// this.initWebSocket();//websocket
},
destroyed() {
this.websock.close() //离开路由之后断开websocket连接
},
methods:{
// initWebSocket(){ //初始化weosocket
// const wsuri = main.url;
// this.websock = new WebSocket(wsuri);
// this.websock.onmessage = this.websocketonmessage;
// this.websock.onopen = this.websocketonopen;
// // this.websock.onopen = this.sendRequest;
// this.websock.onerror = this.websocketonerror;
// this.websock.onclose = this.websocketclose;
// },
// websocketonopen(moduleType, actionType, reqData){
//连接建立之后执行send方法发送数据
// let dat