From 9844bc76eab93a398008319178d35912c5e8a3d9 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E5=A4=9C=E7=AC=99=E6=AD=8C?= <2277317060@qq.com> Date: Fri, 7 Apr 2023 10:39:31 +0800 Subject: [PATCH] =?UTF-8?q?=E6=B7=BB=E5=8A=A0=E8=BF=9E=E6=8E=A5=E5=A4=B1?= =?UTF-8?q?=E8=B4=A5=E9=87=8D=E8=BF=9E?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- ruoyi-ui/src/views/index.vue | 24 ++++++++++++------------ 1 file changed, 12 insertions(+), 12 deletions(-) diff --git a/ruoyi-ui/src/views/index.vue b/ruoyi-ui/src/views/index.vue index 6030753..5d5aca9 100644 --- a/ruoyi-ui/src/views/index.vue +++ b/ruoyi-ui/src/views/index.vue @@ -646,20 +646,20 @@ export default { alert("您的浏览器不支持Websocket通信协议") return } - let url = "ws://10.11.41.249:8080/websocket/message"; //请求的后端地址 - let websocket = null;//全局WebSocket对象 - let lockReconnect = false; // 网络断开重连 - let wsCreateHandler = null; // 创建连接 - - websocket = new WebSocket(url) - websocket.onopen = function(event) { - console.log("服务已连接") - }; - websocket.onmessage = function(event){ - console.log(event) + const getWebsocket = () => { + let websocket = new WebSocket("ws://10.11.41.249:8080/websocket/message") + websocket.onopen = function (event) { + console.log("服务已连接") + }; + websocket.onmessage = function (event) { + console.log(event) + } + websocket.onerror = function (event) { + setTimeout(getWebsocket,1000) + }; } - + getWebsocket() } } }