0
为什么回调中的套接字未定义?套接字在回调中未定义
main.js:26078 Uncaught TypeError: Cannot read property 'on' of undefined
控制台日志是一个Socket对象。
var jwt = sessionStorage.token;
console.log(socket);
socket.on('connect', function (socket) { // undefined socket
socket.on('authenticated', function() {
//do other things
})
.emit('authenticate', {token: jwt}); //send the jwt
});
为什么这里的示例在回调中有一个套接字? https://github.com/auth0/socketio-jwt#example-usage –
@amiawizard - 客户端示例看起来不对。 socket.io客户机doc不显示任何参数给'connect'事件的回调。 – jfriend00
@amiawizard - 这是否回答了您的原始问题? – jfriend00