# webRTC-vue2.0 **Repository Path**: charmingcheng/web-rtc-vue2.0 ## Basic Information - **Project Name**: webRTC-vue2.0 - **Description**: webRTC视频对讲 - **Primary Language**: Unknown - **License**: Not specified - **Default Branch**: master - **Homepage**: None - **GVP Project**: No ## Statistics - **Stars**: 0 - **Forks**: 1 - **Created**: 2025-09-03 - **Last Updated**: 2025-09-03 ## Categories & Tags **Categories**: Uncategorized **Tags**: None ## README # WebRTC实现视频对讲(前端部分VUE) 1. 下载插件socket.io-clint ``` npm install socket.io-client --save ``` 2. 新建socket.js文件 ```js import io from 'socket.io-client'; let test2 = 'http://192.168.3.108:8899' const socket = io.connect(test2); export default socket; ``` 3. 页面正常引入socket.js并正常使用 ```vue import socket from '@/common/js/socket' methods:{ join(){ socket.on('test',data=>{ console.log(data) })//监听 socket.emit('test',{data:data})//发送消息 } } ``` ## 使用vue-socket.io插件连接socket.io 1. 下载插件vue-socket.io ``` npm install vue-socket.io --save ``` 2. 再main.js中使用 并默认开启连接 ```js // 连接socket.io import VueSocketIO from 'vue-socket.io' Vue.use(new VueSocketIO({ debug: true, connection: 'http://192.168.3.108:8899' })) ``` 3. 在页面中使用 ```vue //接收消息 this.sockets.subscribe('joined', (data) => { this.userList = data[0] console.log(data) }) // 发送消息 this.$socket.emit('join', { roomid: this.roomid, account: this.account }) ```