第七色在线视频,2021少妇久久久久久久久久,亚洲欧洲精品成人久久av18,亚洲国产精品特色大片观看完整版,孙宇晨将参加特朗普的晚宴

為了賬號安全,請及時綁定郵箱和手機立即綁定
已解決430363個問題,去搜搜看,總會有你想問的

努力理解為什么我的服務(wù)工作者不工作

努力理解為什么我的服務(wù)工作者不工作

UYOU 2021-11-12 18:19:01
我一直在按照https://www.pwabuilder.com上的說明使我的網(wǎng)站可離線使用。在控制臺日志中,我收到消息,指出 PWA 已安裝,并已離線緩存,但我在標題中收到錯誤消息。我去過許多 stackoverflow 線程和其他網(wǎng)站,但我正在嘗試的任何東西都不起作用。這不是我的強項,我是一名 UX/UI 設(shè)計師,可以編寫簡單的靜態(tài)頁面,但目前這略高于我的技能水平。我真的很難弄清楚如何解決這個問題,因為(對我來說)這個錯誤很模糊。我假設(shè)它是我錯過的一些簡單的東西。網(wǎng)站 url 是https://ovoc.netlify.com/但我也會鏈接下面的清單和服務(wù)工作者清單文件{    "dir": "ltr",    "lang": "en",    "name": "Our voice our community | Get involved in de…",    "scope": "/",    "display": "fullscreen",    "start_url": "https://ovoc.netlify.com/",    "short_name": "OVOC",    "theme_color": "transparent",    "description": "Our voice our community is a project run by BGC Wales to empower young people to engage in community decision making",    "orientation": "any",    "background_color": "transparent",    "related_applications": [],    "prefer_related_applications": false,    "icons": [{    "src": "assets/icons/logo.png",    "sizes": "192x192",    "type": "image/png"  }]}這是服務(wù)人員// This is the "Offline copy of pages" service workerconst CACHE = "pwabuilder-offline";// TODO: replace the following with the correct offline fallback page i.e.: const offlineFallbackPage = "index.html";const offlineFallbackPage = "index.html";// Install stage sets up the index page (home page) in the cache and opens a new cacheself.addEventListener("install", function (event) {  console.log("[PWA Builder] Install Event processing");  event.waitUntil(    caches.open(CACHE).then(function (cache) {      console.log("[PWA Builder] Cached offline page during install");      if (offlineFallbackPage === "index.html") {        return cache.add(new Response("TODO: Update the value of the offlineFallbackPage constant in the serviceworker."));      }      return cache.add(offlineFallbackPage);    })  );});我真的很掙扎,我的客戶是一個慈善機構(gòu),所以我真的很想為他們做這項工作,任何幫助將不勝感激!
查看完整描述

2 回答

?
慕尼黑的夜晚無繁華

TA貢獻1864條經(jīng)驗 獲得超6個贊

如果您訪問https://ovoc.netlify.com/,您應(yīng)該會在 Chrome DevTools 的網(wǎng)絡(luò)面板中看到以下內(nèi)容:

http://img1.sycdn.imooc.com//618e3fbb00017b6315920243.jpg

這表明軟件正在向 URL 發(fā)出請求https://ovoc.netlify.com/[object%20Response],它返回 404 響應(yīng)。

它還告訴您該請求源自pwabuilder-sw.js:17,即您的服務(wù)工作者腳本的第 17 行。

該行對應(yīng)于:

return cache.add(new Response("TODO: Update the value of the offlineFallbackPage constant in the serviceworker."));

這似乎是您需要更新的一些占位符代碼,以放入離線頁面的實際 URL。

此外,您<head>的 標簽包括許多undefined網(wǎng)址:

http://img1.sycdn.imooc.com//618e3fc7000106c108520256.jpg

看起來這些是由 生成的ManUp.js,因此您應(yīng)該確保正確配置。


查看完整回答
反對 回復(fù) 2021-11-12
?
HUH函數(shù)

TA貢獻1836條經(jīng)驗 獲得超4個贊

這是在您的應(yīng)用程序中緩存靜態(tài)資產(chǎn)和動態(tài)資產(chǎn)的工作代碼注意:1)安裝服務(wù)工作者時,它會安裝所有靜態(tài) html、css、js 文件 2)將所有靜態(tài)文件名替換為可用的文件您的應(yīng)用程序 3) 動態(tài)緩存用于緩存經(jīng)常更新的圖像 4) 如果您發(fā)布了需要更新到用戶的新版本,只需將 CACHE_STATIC_NAME 更改為 1 個版本


var CACHE_STATIC_NAME = 'static-v1';

var CACHE_DYNAMIC_NAME = 'dynamic-v1';


self.addEventListener('install', function(event) {

  console.log('[Service Worker] Installing Service Worker ...', event);

  event.waitUntil(

    caches.open(CACHE_STATIC_NAME)

      .then(function(cache) {

        console.log('[Service Worker] Precaching App Shell');

        cache.addAll([

          '/',

          '/index.html',

          '/src/js/app.js',

          '/src/js/feed.js',

          '/src/js/promise.js',

          '/src/js/fetch.js',

          '/src/js/material.min.js',

          '/src/css/app.css',

          '/src/css/feed.css',

          '/src/images/main-image.jpg',

          'https://fonts.googleapis.com/css?family=Roboto:400,700',

          'https://fonts.googleapis.com/icon?family=Material+Icons',

          'https://cdnjs.cloudflare.com/ajax/libs/material-design-lite/1.3.0/material.indigo-pink.min.css'

        ]);

      })

  )

});


self.addEventListener('activate', function(event) {

  console.log('[Service Worker] Activating Service Worker ....', event);

  event.waitUntil(

    caches.keys()

      .then(function(keyList) {

        return Promise.all(keyList.map(function(key) {

          if (key !== CACHE_STATIC_NAME && key !== CACHE_DYNAMIC_NAME) {

            console.log('[Service Worker] Removing old cache.', key);

            return caches.delete(key);

          }

        }));

      })

  );

  return self.clients.claim();

});


self.addEventListener('fetch', function(event) {

  event.respondWith(

    caches.match(event.request)

      .then(function(response) {

        if (response) {

          return response;

        } else {

          return fetch(event.request)

            .then(function(res) {

              return caches.open(CACHE_DYNAMIC_NAME)

                .then(function(cache) {

                  cache.put(event.request.url, res.clone());

                  return res;

                })

            })

            .catch(function(err) {


            });

        }

      })

  );

});



查看完整回答
反對 回復(fù) 2021-11-12
  • 2 回答
  • 0 關(guān)注
  • 216 瀏覽
慕課專欄
更多

添加回答

舉報

0/150
提交
取消
微信客服

購課補貼
聯(lián)系客服咨詢優(yōu)惠詳情

幫助反饋 APP下載

慕課網(wǎng)APP
您的移動學(xué)習(xí)伙伴

公眾號

掃描二維碼
關(guān)注慕課網(wǎng)微信公眾號