简体   繁体   English

在 service-workers 中导入 jquery.js

[英]import jquery.js in service-workers

How can I import jquery in sw.js ( https://github.com/mdn/sw-test/blob/gh-pages/sw.js ) to trigger event?如何在 sw.js ( https://github.com/mdn/sw-test/blob/gh-pages/sw.js ) 中导入 jquery 以触发事件? I tried to use importScripts('path to jquery.js'), but I had the problem : "window isn't defined".我尝试使用 importScripts('path to jquery.js'),但我遇到了问题:“窗口未定义”。

不要导入像 jQuery 这样的基于 DOM 的库,因为 Service Worker 没有 DOM,所以没有文档、XMLHttpRequest 等。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM