带有vue路由器的Vue PWA仅显示空白页

时间:2020-06-03 10:04:04

标签: symfony vue.js single-page-application vue-router progressive-web-apps

我正在使用Symfony和Vue创建SPA,它也应该是具有脱机功能的PWA。我添加了我的服务人员,并且缓存有效,但是当我打开“ /”时,什么都没有显示,只有空白页。

const staticCacheName = 'site-static'; //static resourcess
const assets = [
'/',
'/images/logo.png',
'/build/app.css',
'/build/app.js',
'/build/vendors~app.css',
'/build/vendors~app.js',
'https://pro.fontawesome.com/releases/v5.10.0/css/all.css'
];

//event listener for install-event
self.addEventListener('install', function (event) {
    event.waitUntil(    
        caches.open(staticCacheName).then(cache => {    
            console.log('caching shell assets');
            cache.addAll(assets);
        })
    );
});

//event listener for activate-event
self.addEventListener('activate', function (event) {

});

//event listener for fetch-event
self.addEventListener('fetch', function (event) {
    event.respondWith(
      caches.match(event.request).then(cacheResponse => { 
          return cacheResponse || fetch(event.request); 
      })
    );
});

0 个答案:

没有答案
相关问题