看不到服务人员日志

时间:2018-08-13 11:52:28

标签: javascript google-chrome ecmascript-6 service-worker

看不到我的服务人员的日志。这是我尝试为已注册并正在运行的Service Worker打开日志的步骤。

  1. 打开chrome://serviceworker-internals/
  2. 点击开始并检查
  3. 刷新检查窗口
  4. 等待日志显示

但是,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

0 个答案:

没有答案