小编Joh*_*hnC的帖子

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

我正在尝试为一个小型静态站点设置一个简单的 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,
        })
      ]
    })
  )
Run Code Online (Sandbox Code Playgroud)

workbox

5
推荐指数
1
解决办法
2192
查看次数

标签 统计

workbox ×1