小编Dan*_*ebb的帖子

未捕获(承诺)类型错误:无法在“addAll”上执行“缓存”:渐进式 Web 应用程序上的请求失败

我正在学习一个简单的 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 上找到的几种解决方案,但都没有奏效。

web service-worker

7
推荐指数
1
解决办法
4966
查看次数

使用 google-map-react 放大和缩小时地图标记会移动

我在我的 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)

reactjs google-map-react

7
推荐指数
1
解决办法
1546
查看次数

标签 统计

google-map-react ×1

reactjs ×1

service-worker ×1

web ×1