我正在学习一个简单的 PWA 教程,但是当我完成它时,我收到以下控制台错误,
Uncaught (in promise) TypeError: Failed to execute 'Cache' on 'addAll': Request failed
这是我的 serviceworker 文件
const staticDevCoffee = "dev-coffee-site-v1"
const assets = [
"/",
"/test.html",
"/csstest/style.css",
"/jstest/app.js",
"/coffee.png",
]
self.addEventListener("install", installEvent => {
installEvent.waitUntil(
caches.open(staticDevCoffee).then(cache => {
cache.addAll(assets)
})
)
})
Run Code Online (Sandbox Code Playgroud)
当我运行灯塔测试时,我得到了这个,
start_url does not respond with a 200 when offlineThe start_url did respond, but not via a service worker.
Run Code Online (Sandbox Code Playgroud)
这是我第一次看到 PWA,所以我有点卡住了。我已经尝试了在 SO 上找到的几种解决方案,但都没有奏效。
我在我的 React 应用程序中添加了一张带有标记的地图,标记了固定位置,一切正常,但如果我缩小,标记会四处移动并进一步移动到它应该做的位置的右侧。
import GoogleMapReact from 'google-map-react';
import { Icon } from '@iconify/react'
import locationIcon from '@iconify/icons-mdi/map-marker'
import './map.css'
interface Props {
location: {
address: string,
lng: number,
lat: number
}
}
const LocationPin = ({ address }: Props["location"]) => (
<div className="pin">
<Icon icon={locationIcon} className="pin-icon" style={{ fontSize: '60px' }} />
<p className="pin-text">{address}</p>
</div>
)
export default function SimpleMap(){
const defaultProps = {
center: {
lat: 53.5050,
lng: -2.0300
},
zoom: 12
};
return (
// Important! Always set the …Run Code Online (Sandbox Code Playgroud)