【问题标题】:Unable to find Client in FetchEvent for Firefox 44.0.2无法在 Firefox 44.0.2 的 FetchEvent 中找到客户端
【发布时间】:2016-02-15 17:19:58
【问题描述】:

我正在使用这段代码来获取客户端。但它仍然是客户端不匹配。

this.addEventListener('fetch', function(event) {
var client=null;
if(event.client != null){
    client=event.client;
}else if(event.clientId!=null){
    client=Clients.get(event.clientId);
}else{
    console.log("Client Not Matched.");
}

}

【问题讨论】:

    标签: firefox service-worker fetch-api


    【解决方案1】:

    client 属性已弃用 (https://developer.mozilla.org/en-US/docs/Web/API/FetchEvent/client)。

    从 Firefox 45 (https://developer.mozilla.org/en-US/docs/Web/API/FetchEvent/clientId) 开始支持 clientId 属性。

    根据您的需要,您或许可以使用clients.matchAll (https://developer.mozilla.org/en-US/docs/Web/API/Clients)。

    【讨论】:

      猜你喜欢
      • 2017-06-15
      • 2013-05-01
      • 2011-06-29
      • 2016-06-04
      • 2020-12-10
      • 1970-01-01
      • 2023-04-07
      • 1970-01-01
      • 2013-06-06
      相关资源
      最近更新 更多