Apache2 灯上的维修工人不';不存在
我正在根据“”测试serviceWorker 使用Ubuntu 18.04、apache2 v2.4.29、firefox 69.0.1的我的电脑 我看到serviceWorker不仅在HTTPS域上运行,而且在端口80和本地主机上进行测试 我在我的一个测试域outilsrouteur.test上测试它,其中/etc/apache2/sites available/outilsrouteur.test.conf是:Apache2 灯上的维修工人不';不存在,apache2,port,service-worker,lamp,Apache2,Port,Service Worker,Lamp,我正在根据“”测试serviceWorker 使用Ubuntu 18.04、apache2 v2.4.29、firefox 69.0.1的我的电脑 我看到serviceWorker不仅在HTTPS域上运行,而且在端口80和本地主机上进行测试 我在我的一个测试域outilsrouteur.test上测试它,其中/etc/apache2/sites available/outilsrouteur.test.conf是: <VirtualHost *:80> ServerN
<VirtualHost *:80>
ServerName outilsrouteur.test
ServerAlias www.outilsrouteur.test
DocumentRoot ***/siteoutilsrouteur // *** = my real directory
<Directory ***/siteoutilsrouteur> // *** = my real directory
DirectoryIndex index.html index.php
Options SymLinksIfOwnerMatch
AllowOverride all
Require local
</Directory>
ErrorLog ***/siteoutilsrouteur/error.log.txt
CustomLog /access.log combined
</VirtualHost>
Listen 80
我几乎没有将app.js修改为:
console.log("===================\napp.js :\n\n"); //****
if ('serviceWorker' in navigator) {
console.log("serviceWorker existe");
navigator.serviceWorker.register('./sw-test/sw.js', {scope: './sw-test/'})
.then((reg) => {
// registration worked
console.log('Registration succeeded. Scope is ' + reg.scope);
}).catch((error) => {
// registration failed
console.log('Registration failed with ' + error);
});
} else { //****
console.log("serviceWorker n'existe pas / doesn't exist : '"+location.port+"'"); //****
}
我以为我的灯在监听端口80工作,但是,当我调用我的测试页面时(第一步):
因此,我的测试运行,但是位置端口不是80,并且不存在serviceWorker
您能给我看看我的mystake吗?好的,在mdn页面底部: 测试时,您可以通过检查 中的“通过HTTP启用服务工作者(工具箱打开时)”选项 Firefox开发者工具设置 它确实起作用
<html>
<head>
<meta charset="utf-8">
<meta http-equiv="X-UA-Compatible" content="IE=edge,chrome=1">
<meta name="viewport" content="width=device-width">
<title>SW map</title>
<body>
<h1>Pour voir</h1>
<section></section>
<script src="app.js"></script>
</body>
</html>
===================
app.js :
app.js:1:9
serviceWorker n'existe pas / doesn't exist : ''