chrome 不支持 Service Worker (69.0.3497.81) [英] Service worker is not supported in chrome (69.0.3497.81)
问题描述
我开始使用 PWA(渐进式网络应用程序).当我尝试检查 Chrome 浏览器中是否支持 Service Worker 时,它总是返回 false.下面是我用于检查的代码.
I am start working with PWA (Progressive web app). When I try to check service worker is supported or not in chrome browser.It always return false. Below code I used for the checking.
注意:我使用的是 chrome 版本 69.0.3497.81(官方版本)(64 位).
Note: I am using chrome Version 69.0.3497.81 (Official Build) (64-bit).
app.js
if ('serviceWorker' in navigator) {
navigator.serviceWorker.register('/sw.js').then(function() {
console.log('service worker registered');
});
}
需要帮助在 Chrome 中注册 Service Worker.
Need help to register service worker in chrome.
推荐答案
这个问题是由于我在 上运行我的应用程序造成的http://192.168.1.11:8080 但是当我将域切换到 http://localhost:8080/>.它工作正常.
This problem is cause due to I am running my application on http://192.168.1.11:8080 but when I switch domain to http://localhost:8080/. it's working fine.
Chrome 要求通过 https 为 Service Worker 提供服务,但允许 localhost 的开发例外.
Chrome requires service workers to be served over https, but allows an exception for localhost for development.
这篇关于chrome 不支持 Service Worker (69.0.3497.81)的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!