websocket 封装(含心跳,重连机制,强制退出)/** * @param {JSON} json 连接建立立即发送,如果想不发送就传' ', * @param {String} url * @param {Function} callback 接收服务端数据时触发的回调 * @param {Object} protocol 第二个参数 protocol 是可选的,指定了可接受的子协议。 */ const WS = function (json, url, callback, protocol) { this.json = json; this.url = url; this.protocol = typeof (protocol) == 'undefined' ? null : protocol || '' this.reconnect_time = 0; //重连的时间 this.reconnect_count = 0; //重连次数 this.is_destroy = false //强制关闭 this.is_reconnect
1. 获取当前时间 let nowDate = new Date();2.获取年月日时分秒 let year = nowDate.getYear(); // 获取当前年份(2位) let year2 = nowDate.getFullYear(); // 获取完整的年份(4位,1970-????) let = nowDate.getMonth(); // 获取当前月份(0-11,0代表1月) nowDate.getDate(); // 获取当前日(1-31) let day = nowDate.getDay(); // 获取当前星期X(0-6,0代表星期天) let time = nowDate.getTime(); // 获取当前时间(从1970.1.1开始的毫秒数) let hours = nowDate.getHours(); // 获取当前小时数(0-23) let minutes = nowDate.getMinutes(); // 获取当前分钟数(0-59) let secon
hookiang
7年编程经验,PHP和Java都略懂一些,做过前端开发