简单介绍项目使用的插件:
"dependencies": {
"express": "^4.16.3",
"socket.io": "^2.1.0",
"vue": "^2.5.2",
"vue-router": "^3.0.1",
"vue-socket.io": "^2.1.1-b",
"vuex": "^3.0.1"
}
第一步构建node服务器:
const express = require('express');
const server = express();
const app = express().listen(80);
const io = require('socket.io').listen(app);
io.sockets.on('connection', (socket) => {
console.log('连接成功');
socket.emit('login', 'loginSuccess');
socket.on('toggle', value => {
console.log(value);
socket.emit('toggle', !value);
})
});
第二步修改配置文件(config目录下的index.js),
原来proxyTable为空对象,先加入以下内容&