问题
Is it possible to call a function from a JavaScript file out of an ServiceWorker?
Directory
root
static
js
serviceworker.js
tmpBuild
js
pages
Overview.js
serviceworker.js has to call a method from Overview.js! Is that possible? And How?
回答1:
You can use importScripts() https://developer.mozilla.org/en-US/docs/Web/API/WorkerGlobalScope/importScripts
importScripts('https://example.com/script.js');
来源:https://stackoverflow.com/questions/46932176/can-i-call-a-method-from-an-external-js-file-in-a-serviceworker