不允许加载本地资源:chrome-error://chromewebdata/favicon@2x.png chrome-error:// chromewebdata/

发布于 2025-02-08 07:41:02 字数 1525 浏览 3 评论 0原文

我正在关注 pwa教程贮存。 除指定的错误外,我还收到了以下警告,

The FetchEvent for "https://localhost:7047/Shop/Catalog" resulted in a network error response: an object that was not a Response was passed to respondWith().

我安装了内容的Web清单:

{
    "name": "To table",
    "short_name": "To table",
    "description": "Excellent marketplace",
    "icons": [
        {
            "src": "/android-chrome-192x192.png",
            "sizes": "192x192",
            "type": "image/png",
            "purpose": "maskable"
        },
        {
            "src": "/android-chrome-512x512.png",
            "sizes": "512x512",
            "type": "image/png"
        }
    ],
    "theme_color": "#ffffff",
    "background_color": "#ffffff",
    "start_url": "/",
    "display": "standalone"
}

我的布局中有这些标签,并在指定文件夹中有相应的图像。

<link rel="apple-touch-icon" sizes="180x180" href="/apple-touch-icon.png">
<link rel="icon" type="image/png" sizes="32x32" href="/favicon-32x32.png">
<link rel="icon" type="image/png" sizes="16x16" href="/favicon-16x16.png">
<link rel="manifest" href="/site.webmanifest">
<link rel="mask-icon" href="/safari-pinned-tab.svg" color="#5bbad5">
<meta name="msapplication-TileColor" content="#da532c">
<meta name="theme-color" content="#ffffff">

I'm following PWA tutorial and the same way implemented offline storage.
In addition to the specified error, I got the following warnings

The FetchEvent for "https://localhost:7047/Shop/Catalog" resulted in a network error response: an object that was not a Response was passed to respondWith().

I have web manifest installed with content:

{
    "name": "To table",
    "short_name": "To table",
    "description": "Excellent marketplace",
    "icons": [
        {
            "src": "/android-chrome-192x192.png",
            "sizes": "192x192",
            "type": "image/png",
            "purpose": "maskable"
        },
        {
            "src": "/android-chrome-512x512.png",
            "sizes": "512x512",
            "type": "image/png"
        }
    ],
    "theme_color": "#ffffff",
    "background_color": "#ffffff",
    "start_url": "/",
    "display": "standalone"
}

I have these tags in my layout and corresponding images in specified folders.

<link rel="apple-touch-icon" sizes="180x180" href="/apple-touch-icon.png">
<link rel="icon" type="image/png" sizes="32x32" href="/favicon-32x32.png">
<link rel="icon" type="image/png" sizes="16x16" href="/favicon-16x16.png">
<link rel="manifest" href="/site.webmanifest">
<link rel="mask-icon" href="/safari-pinned-tab.svg" color="#5bbad5">
<meta name="msapplication-TileColor" content="#da532c">
<meta name="theme-color" content="#ffffff">

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(1

止于盛夏 2025-02-15 07:41:02

我在代码上犯了一个错误。我忘了致电recondwith的处理程序:

self.addEventListener(`fetch`, (e: any) => {
    e.respondWith((async () => {
        const r = await caches.match(e.request)
        if (r) {
            return r
        }
        const response = await fetch(e.request)
        const cache = await caches.open(cacheName)
        cache.put(e.request, response.clone())
        return response
    }))
})

正确:

self.addEventListener(`fetch`, (e: any) => {
    e.respondWith((async () => {
        const r = await caches.match(e.request)
        if (r) {
            return r
        }
        const response = await fetch(e.request)
        const cache = await caches.open(cacheName)
        cache.put(e.request, response.clone())
        return response
    })())
})

I made a mistake in code. I forgot to call handler of respondWith:

self.addEventListener(`fetch`, (e: any) => {
    e.respondWith((async () => {
        const r = await caches.match(e.request)
        if (r) {
            return r
        }
        const response = await fetch(e.request)
        const cache = await caches.open(cacheName)
        cache.put(e.request, response.clone())
        return response
    }))
})

Correct:

self.addEventListener(`fetch`, (e: any) => {
    e.respondWith((async () => {
        const r = await caches.match(e.request)
        if (r) {
            return r
        }
        const response = await fetch(e.request)
        const cache = await caches.open(cacheName)
        cache.put(e.request, response.clone())
        return response
    })())
})
~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文