socket.conneted

  • (Boolean)

socket是否连接到服务器。

  1. const socket= io('http://localhost');
  2. socket.on('connect',()=>{
  3. console.log(socket.connected) //true
  4. })