From 3b0f3b4310d7cad3bd61d0fbfcbc2f81d9cc6713 Mon Sep 17 00:00:00 2001 From: Thomas Citharel Date: Sat, 8 May 2021 14:41:17 +0200 Subject: Fix a typo in the example for CacheStorage.keys() (#781) Follow-up to https://github.com/mdn/content/pull/4790 on the main repo Signed-off-by: Thomas Citharel --- files/zh-cn/web/api/cachestorage/keys/index.html | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'files/zh-cn') diff --git a/files/zh-cn/web/api/cachestorage/keys/index.html b/files/zh-cn/web/api/cachestorage/keys/index.html index 8d174f9c2c..57f7148a28 100644 --- a/files/zh-cn/web/api/cachestorage/keys/index.html +++ b/files/zh-cn/web/api/cachestorage/keys/index.html @@ -26,7 +26,7 @@ translation_of: Web/API/CacheStorage/keys

在此代码片段中,我们监听{{domxref("ServiceWorkerGlobalScope.onactivate", "activate")}} 事件,然后运行一个 {{domxref("ExtendableEvent.waitUntil","waitUntil()")}} 方法,该方法在新的 service worker 被激活之前清除老的、无用的cache。 这里我们设置一个包含缓存名称的白名单。 通过使用 keys()方法 来返回{{domxref("CacheStorage")}} 对象中的keys集合,然后检查缓存key是否在白名单中,如果不存在,则使用 {{domxref("CacheStorage.delete")}} 方法来删除该缓存。

-
then.addEventListener('activate', function(event) {
+
this.addEventListener('activate', function(event) {
   var cacheWhitelist = ['v2'];
 
   event.waitUntil(
-- 
cgit v1.2.3-54-g00ecf