vue.js Chrome lighthouse报告在“最佳实践”部分返回“正确定义字符集”问题

jaxagkaj  于 2023-10-23  发布在  Vue.js
关注(0)|答案(2)|浏览(97)

我有一个VueJs SPA应用。一切正常。但是当我运行Chrome灯塔报告时,它返回Properly defines charset错误。事实上,我已经在index.html文件中添加了字符集。

以下是问题的截图。

  • Chrome灯塔报告 *

  • 最佳实践中的Chrome灯塔问题 *

  • 添加字符集UTF-8的代码 *

dsekswqp

dsekswqp1#

这是服务工人的问题。我无意中重复注册了服务人员。这就是为什么它产生问题。

m0rkklqb

m0rkklqb2#

我有同样的问题,它也指向worker和我的worker安装:

self.addEventListener("install", event => {
    event.waitUntil(installEvent());
    self.skipWaiting();
});

async function installEvent() {
    const response = await fetch(createCacheBustedRequest(OFFLINE_URL));
    const cache = await caches.open(CURRENT_CACHES.offline);
    await cache.put(OFFLINE_URL, response);
}
// od poprawnego przeładowania zakłądek
self.addEventListener('message', async event => {
    if (event.data === 'reloadClients') {
        const clients = await self.clients.matchAll({type: 'window'});
        for (const client of clients) {
            client.navigate(client.url);
        }
    }
});

self.addEventListener("activate", event => {
    event.waitUntil(handleActivation());
    self.clients.claim();
});

async function handleActivation() {
    let cacheNames = await caches.keys();
    let validCacheNames = Object.values(CURRENT_CACHES);
    let deletePromises = [];

    for(let cacheName of cacheNames) {
        if(!validCacheNames.includes(cacheName)) {
            //console.log("Deleting out of date cache:", cacheName);
            deletePromises.push(caches.delete(cacheName));
        }
    }

    await Promise.all(deletePromises);
    
    // Po wykonaniu wszystkich operacji czyszczenia, przeładuj wszystkie zakładki przeglądarki.
    self.clients.matchAll({type: 'window'}).then(windowClients => {
      windowClients.forEach(windowClient => {
        windowClient.navigate(windowClient.url);
      });
    });
}

相关问题