Socket.io教程不打印连接到控制台

var app = require('express')(); var http = require('http').Server(app); var io = require('socket.io')(http); app.get('/', function(req, res){ res.sendFile(__dirname + "/index.html"); }); http.listen(3000, function() { console.log('listening on 3000'); }); io.on('connection', function(socket){ console.log('a user connected'); socket.on('disconnect', function(){ console.log('user disconnected'); }); }); 

我不明白为什么当我刷新页面时不打印“连接的用户”,我想知道为什么。 以下是index.html文件。 我正在学习入门教程( http://socket.io/get-started/chat/ )

 <!DOCTYPE html> <html> <head> <title>Socket.IO chat</title> <style type="text/css"> * { margin: 0; padding: 0; box-sizing: border-box; } body { font: 13px Helvetica, Arial; } form { background: #000; padding: 3px; position: fixed; bottom: 0; width: 100%; } form input { border: 0; padding: 10px; width: 90%; margin-right: 0.5%; } form button { width: 9%; background: rgb(130, 224, 255); border: none; padding: 10px; } #messages { list-style-type: none; margin: 0; padding: 0; } #messages li { padding: 5px 10px; } #messages li:nth-child(odd) { background: #eee; } </style> </head> <body> <ul id="messages"> <form action=""> <input id="m" autocomplete="off" /> <button>Send</button> </form> </ul> <script src="socket.io/socket.io.js"> var socket = io(); </script> </body> 

       

网上收集的解决方案 "Socket.io教程不打印连接到控制台"