Uncaught ReferenceError: Invalid left-hand side in assignment
在我的控制台中引用JS文件中的行
let message = data.msg;
在本节中:
socket.on('status', data => {
let message = data.msg;
document.querySelectorAll('#messages') += message;
});
我试着写作
data.msg
我怎样才能进入我的房间,只在那个房间里聊天?我需要允许用户创建他们想要的任意多个。
下面是烧瓶中的路线:
@socketio.on('join')
def on_join(data):
username = data['username']
room = data['room']
join_room(room)
emit("status", {'msg': username + 'has joined the room'}, room=room)
以下是附带的JS:
var socket = io.connect(location.protocol + '//' + document.domain + ':' + location.port);
if (!socket) console.log("Socket not connected!");
socket.on('connect', () => {
console.log("socket connected");
// after socket connect, configure channel button
document.querySelectorAll('button').forEach(button => {
button.onclick = () => {
console.log("button click fired!");
let username = localStorage["login"]
let room = button.dataset.room;
console.log("ChannelName" + room);
socket.emit("join", {'username':username, "room":room});
};
});
socket.on('status', data => {
console.log("JOINED!")
let message = data.msg;
document.querySelectorAll('#messages') += message;
});
注意,错误发生在右侧
分配给
#message
部门。
编辑
解包错误会显示对io所需的缩小JS文件的多个引用。它在花园里
<head>
第节
layout.html
. 放置在
<body>
messages:134 Uncaught ReferenceError: Invalid left-hand side in assignment
at r.socket.on.data (messages:134)
at r.n.emit (socket.io.min.js:1)
at r.onevent (socket.io.min.js:1)
at r.onpacket (socket.io.min.js:1)
at n.<anonymous> (socket.io.min.js:1)
at n.emit (socket.io.min.js:1)
at n.ondecoded (socket.io.min.js:1)
at s.<anonymous> (socket.io.min.js:1)
at s.n.emit (socket.io.min.js:1)
at s.add (socket.io.min.js:2)