我正在尝试将触摸事件对象编码为 JSON 以通过 websockets 发送它,出现错误消息:
未捕获的 TypeError:将循环结构转换为 JSON
当您拥有直接是对象本身的对象属性时会发生错误。那么,通过 websocket 发送多点触控事件的方法是什么?
document.addEventListener('touchmove', function(event) {
console.log(event);
event = JSON.stringify(event.touches); // Error!
connection.send(event);
}, false);