From 61295cc850145ff197f1f29136fe2e3d90cd393a Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E5=A4=9C=E7=AC=99=E6=AD=8C?= <2277317060@qq.com> Date: Mon, 9 Dec 2024 16:21:57 +0800 Subject: [PATCH] =?UTF-8?q?=E4=BF=AE=E6=94=B9=E7=9C=8B=E6=9D=BF?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- ruoyi-ui/src/views/board/index2.vue | 29 +++++++++++++++++++++++++---- 1 file changed, 25 insertions(+), 4 deletions(-) diff --git a/ruoyi-ui/src/views/board/index2.vue b/ruoyi-ui/src/views/board/index2.vue index cccb9a7..da9c3b7 100644 --- a/ruoyi-ui/src/views/board/index2.vue +++ b/ruoyi-ui/src/views/board/index2.vue @@ -3,7 +3,7 @@
赛轮智慧热电无人巡检系统
{{ i.name }}
- +
{{ parseTime(new Date(), '{y}.{m}.{d} {h}:{i}:{s} 周{a}') }}
智能巡检
无线测温
@@ -38,7 +38,7 @@
- + @@ -157,7 +157,7 @@ export default { Chart }, mounted() { - + this.getData() this.$refs.chart1.setData({ grid: { top: 30, @@ -369,7 +369,28 @@ export default { ] }) }, - methods: {} + methods: { + getData(){ + // 创建一个新的WebSocket实例 + const socket = new WebSocket('ws://192.168.2.165:7181/ws'); + +// 当WebSocket打开时触发 + socket.onopen = function(event) { + console.log('WebSocket 连接已打开'); + }; + +// 当服务器发送消息时触发 + socket.onmessage = function(event) { + console.log('收到消息:', event.data); + }; + +// 当WebSocket关闭时触发 + socket.onclose = function(event) { + console.log('WebSocket 连接已关闭'); + }; + + } + } }