Warning: file_get_contents(/data/phpspider/zhask/data//catemap/9/javascript/452.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181

Warning: file_get_contents(/data/phpspider/zhask/data//catemap/5/objective-c/26.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Javascript 在AngularJS中使用ServiceWorkers_Javascript_Angularjs_Service Worker - Fatal编程技术网

Javascript 在AngularJS中使用ServiceWorkers

Javascript 在AngularJS中使用ServiceWorkers,javascript,angularjs,service-worker,Javascript,Angularjs,Service Worker,这个答案有一些有用的地方,但我仍然遇到一些问题 奇怪的是,我知道服务人员在我的设置上工作,因为我已经通过了wittr演示,并且已经接触了一些服务人员 现在我正在尝试在我的angularJS应用程序中设置服务人员。我的canary devtools控制台中出现以下错误: GET http://localhost:9000/sw.js net::ERR_INSECURE_RESPONSE ServiceWorker registration failed: DOMException: Faile

这个答案有一些有用的地方,但我仍然遇到一些问题

奇怪的是,我知道服务人员在我的设置上工作,因为我已经通过了wittr演示,并且已经接触了一些服务人员

现在我正在尝试在我的angularJS应用程序中设置服务人员。我的canary devtools控制台中出现以下错误:

GET http://localhost:9000/sw.js net::ERR_INSECURE_RESPONSE

ServiceWorker registration failed:  DOMException: Failed to register a ServiceWorker: The script has an unsupported MIME type ('text/html')
我几乎是在复制和粘贴示例文件。它是否与构建过程有关,或者与文件如何在本地提供有关(两者都在本地主机上运行)

我构建了angular应用程序,示例应用程序与angular无关,这是我唯一能想到的


如果有人能给我指出正确的方向,我将不胜感激

呃,答案非常简单,我引用了错误的文件路径名。一旦设置正确,错误就消失了。这只是一条令人困惑的错误消息。

现在我感到困惑。在resources->Service Workers窗口中,它显示了两个选项卡,在local host(本地主机)下,它将Service worker列为active(活动),但在下面,它将列出相同的worker(已停止,处于冗余状态)。当我删除多余的一个,它似乎是工作,我应该忽略错误吗?