Socket.emit('delLoginSys')主体似乎工作正常,它正在发送到html,但未被接收。 `
var io = require('socket.io')(serv, {});
io.sockets.on('connection', function(socket) {
console.log("[DevLog] A Client has connected.");
socket.on('Login', function(data) {
var userVal = data.userVal;
var passVal = data.passVal;
if (userVal === "admin" && passVal === "password") {
console.log("[DevLog] A Client has logged in.");
socket.emit('delLoginSys');
}
});
});
这是html
<script>
var socket = io();
function LoginButton(data) {
var userVal = document.getElementById("emailInput").value;
var passVal = document.getElementById("passInput").value;
socket.emit('Login', {userVal: userVal, passVal: passVal});
}
socket.on('delLoginSys', function() {
document.getElementById("UserSec").parentElement.removeChild();
console.log("del");
});
</script>