websocket基本模式,代码如下
先在data定义以下字段:
data() {
return {
websock: null,
notifications: {
}
};
},
initWebSocket() {
const userInfo = sessionStorage.getItem("userInfo");
// console
if (!userInfo) {
return
} else {
const userId = JSON.parse(userInfo).id;
// console.log("已登录");
// this.open();
//初始化weosocket
const wsuri = `ws://${
this.$root.ipUrl}:8495/wsserver/${
userId}`;
thi