src/views/socket-demo.vue
@@ -3,7 +3,8 @@ <h1>{{ msg }}</h1> <button @click="connect">连接</button> <button @click="disconnect">断开连接</button> <button @click="sendMessage">发送消息</button> <button @click="sendMessage">msg</button> <button @click="sendMessage2">msg2</button> </div> </template> @@ -15,7 +16,7 @@ data () { return { socketIoClient: null, msg: 'Welcome to Your Vue.js App' msg: 'Socket.io 测试页' } }, methods: { @@ -42,6 +43,9 @@ }, sendMessage(){ this.socketIoClient.emit("msg","99999999999") }, sendMessage2(){ this.socketIoClient.emit("msg2","00000") } }, }