服务工作者中的importScripts

问题描述 投票:1回答:2

我试图通过Jakes Archibald's promise-based IDB lib通过importScripts使用IndexedDB,但只要我通过Chrome Dev Tools选择“离线”,我就会得到An unknown error occurred when fetching the script。一个有趣的事情是,即使关闭我的本地主机服务器我的应用程序工作正常(我通过Chrome开发工具禁用了浏览器缓存)我的服务工作者安装浏览器,但在另一个,当然,它没有。

我查看了这些https://www.w3.org/TR/service-workers/#importscriptshttps://github.com/w3c/ServiceWorker/issues/106资源,但我没有找到解决我问题的方法。

任何帮助/解释将不胜感激。

service-worker indexeddb
2个回答
0
投票

问题可能是您没有缓存idb.js文件,以便服务工作者可以在您的应用离线时访问它。

尝试使用cache.add(或cache.addAll,如果你正在缓存多个文件)在install回调中添加它。


-2
投票

这是我创建的库。它使得使用IndexedDB变得更加容易!完全客户端,没有依赖!

https://github.com/ryanwaite28/promise-db

© www.soinside.com 2019 - 2024. All rights reserved.