所以我在 node.js 中有自己的类,称为 -test.js其中有一个名为bla()
在我的 node1 中,我执行以下操作。
const t = new test();
io.emit('event', t);
在我的node2上,
socket.on('event', (t) => {
console.log(t); // this prints the correct output which means sockets work fine.
const aha = t.bla(); // this results in a function not found.
})
看起来一个对象正在共享,但不是实际的实例。我该如何解决?