websocket封装,有心跳和断开重联功能
一、新建文件夹websocket,在文件夹中新建index.js文件。
index.js文件如下
import store from '../store'
const socket = {
$ws: null, // websocket对象
lockReturn: false, // 重连锁
timeout: 60 * 1000 * 5, // 5分钟重连
timeoutObj: null, // setInterval()定时器id
timeoutNum: null, //
原创
2020-08-27 11:45:59 ·
625 阅读 ·
1 评论