guoshilong
2023-03-22 10bc47a275dfd896ba4e72f073d9f901c5390597
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
<template>
  <basic-container>测试页</basic-container>
</template>
 
<script>
  export default {
    data(){
      return{
 
      }
    },
    mounted() {
      let url = 'ws://localhost:88/ws/roo/user_haha'
      // 创建websocket连接
      this.websock = new WebSocket(url);
      // 监听打开
      this.websock.onopen= this.websockOpen;
      // 监听关闭
      this.websock.onclose = this.websockClose;
      //监听异常
      this.websock.onerror = this.websockError;
      //监听服务器发送的消息
      this.websock.onmessage = this.websockMessage;
 
    }
  };
</script>
 
<style>
</style>