gpt4 book ai didi

Workbox 5 语法错误 - 未捕获的类型错误 : workbox. 到期。CacheableResponsePlugin 不是构造函数

转载 作者:行者123 更新时间:2023-12-03 15:43:13 25 4
gpt4 key购买 nike

我正在尝试为一个小型静态站点设置一个简单的 Service Worker,但出现 Service Worker 控制台错误:sw.js:59 Uncaught TypeError: workbox.expiration.CacheableResponsePlugin is not a constructor这是在线 new workbox.expiration.CacheableResponsePlugin任何有关如何解决此问题的建议将不胜感激。

  workbox.routing.registerRoute(
/\.(?:html)$/,
new workbox.strategies.NetworkFirst({
cacheName: 'html-cache',
plugins: [
new workbox.expiration.CacheableResponsePlugin({
statuses: [0, 200],
}),

new workbox.expiration.ExpirationPlugin({
maxEntries: 50,
maxAgeSeconds: 5 * 60,
})
]
})
)

最佳答案

我是从 workbox 迁移过来的v4 到 v5 并有同样的问题。

在您的代码中,

new workbox.expiration.CacheableResponsePlugin

应该
new workbox.cacheableResponse.CacheableResponsePlugin

关于Workbox 5 语法错误 - 未捕获的类型错误 : workbox. 到期。CacheableResponsePlugin 不是构造函数,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/60310455/

25 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com