有没有一种方法可以使用Chrome DevTools来查看一个
BroadcastChannel
中正在发生的事情,而不是附加一个message
事件监听器,这样我就可以看到谁在使用postMessage
发送了什么?BroadcastChannel
中正在发生的事情,而不是附加一个message
事件监听器,这样我就可以看到谁在使用postMessage
发送了什么?postMessage
原型:(function(postMessage) {
BroadcastChannel.prototype.postMessage = function (message) {
debugger;
postMessage.call(this, message);
};
}(BroadcastChannel.prototype.postMessage));
当然,您可以将debugger
语句替换为其他内容,例如 console.trace(message)
,然后在控制台中直接打印调用堆栈。
希望这对您有所帮助。