看不到我的服务人员的日志。这是我尝试为已注册并正在运行的Service Worker打开日志的步骤。
chrome://serviceworker-internals/
但是,chrome://serviceworker-internals/
和ServiceWorker的检查都显示零日志。
但是,“检查”页面上的“源”选项卡显示了最新代码,应打印console.log
这是我正在尝试查看的日志的源代码
messaging.setBackgroundMessageHandler(payload => {
const title = payload.notification.title;
console.log(payload.notification);
const options = {
body: payload.notification.body,
icon: payload.notification.icon,
click_action: payload.notification.click_action || payload.data.click_action,
link: payload.notification.link || payload.data.link,
data: {
time: new Date(Date.now()).toString(),
},
};
return self.registration.showNotification(title, options);
});
self.addEventListener("notificationclick", function(event) {
const notification = event.notification;
notification.close();
console.log(notification);
const promiseChain = clients.openWindow('https://helloworld.com');
event.waitUntil(promiseChain);
});
我正在使用Chrome v68.0.3440.106,MacOS v10.13.6