我想从后台发送chrome.runtime.sendMessage
并在后台抓住它。
我在background.js
-
chrome.runtime.onMessage.addListener(messageListener);
function messageListener (request, sender, sendResponse) {
switch (request.action) {
case "backgroundEvent1":
console.log("backgroundEvent1"); // Not appear
break;
}
}
chrome.runtime.sendMessage({ action: "backgroundEvent1" });
我如何在背景中发送消息并再次在后台捕获它?
(PS - 我已经了解了除chrome.runtime.sendMessage
之外的其他方式)