ソースを参照

菜单消息数量

iZaiZaiA 2 年 前
コミット
2460c3247c
1 ファイル変更4 行追加3 行削除
  1. 4 3
      src/layout/index.vue

+ 4 - 3
src/layout/index.vue

@@ -263,9 +263,10 @@ const setInitSocket = () => {
         console.log('websocket连接已断开')
     };
     socket.onmessage = function ({data}) {
-        let msg = JSON.parse(data)
-        msgCount.value = msg
-        console.log(msg)
+        if (data) {
+            msgCount.value = JSON.parse(data)
+        }
+        console.log(data)
     };
     socket.onerror = function ({data}) {
         console.log('发生错误:', data)