标签: statamic

Service Worker fetch 事件未触发

我有一个网站,我在根目录安装了一个 Service Worker,甚至将范围设置为“/”,如此处所述:Service Worker 正在缓存文件,但从未触发 fetch 事件

但是, fetch 事件没有触发。任何帮助表示赞赏。

importScripts('/site/themes/libs/cache-polyfill.js');

self.addEventListener('install', function (e) {
  e.waitUntil(
    caches.open('v1').then(function (cache) {
      return cache.addAll([
        '/',
        '/test-page',
        '/site/themes/css/main.css',
        '/site/themes/js/vendors.min.js',
        '/site/themes/js/app.min.js'
      ]);
    })
  );

  self.skipWaiting()
});

self.addEventListener('fetch', function (event) {
  console.log(event.request.url);
  event.respondWith(
    caches.match(event.request).then(function (response) {
      return response || fetch(event.request);
    })
  );
});
Run Code Online (Sandbox Code Playgroud)

编辑:我在网站上使用 statamic。

javascript statamic service-worker

6
推荐指数
1
解决办法
3548
查看次数

Axios params没有正确附加到URL

我正在尝试使用params来使用Axios进行发布请求.但是,当我在Chrome中检查XHR时,params似乎没有附加到URL.

如果我这样做,它的工作原理:

axios.post('/!/Like/like?id=' + this.id + '&_token=' + this.csrf_token)
Run Code Online (Sandbox Code Playgroud)

但如果我试试这个,我会收到一个错误:

axios.post('/!/Like/like', {
    params: {
        id: this.id,
        _token: this.csrf_token
    }
})
Run Code Online (Sandbox Code Playgroud)

换句话说,网址必须是:

/!/Like/like?id=1234&_token=zYXW-123
Run Code Online (Sandbox Code Playgroud)

我有什么想法可能做错了吗?

statamic vue.js axios vuejs2

3
推荐指数
1
解决办法
2007
查看次数

Statamic 如何缓存内容?

我想尝试 Statamic(基于文件的 CMS,http: //statamic.com/ ),但我无法获得有关其缓存策略的信息。我担心有很多 I/O 操作,尤其是在使用高级技术时 - 标记、使用附加组件等。

您是否购买了 Statamic 并且可以确认/反驳我的担忧?

php caching content-management-system statamic

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

SwiperJS 延迟加载 - 按照指南所述使用 data-src 时图像不显示

我一直在努力尝试将 SwiperJS 实现到我的 Statamic 3 项目中。

我有一个工作轮播/滑块,当不使用 data-src 和延迟加载时工作得很好。但一旦我尝试按照他们网站上的指南实现延迟加载。我得到带有无限加载程序的白色图像/背景或没有加载程序的白色图像/背景。

这是我的代码:

HTML(图像来自鹿角):

<div class="flex flex-col w-1/3 p-2">
    <div class="h-full w-full swiper-container">
        <div class="h-48 swiper-wrapper">
            {{ foreach:photos }}
                <div class="swiper-slide">
                    <img data-src="{{ value:url }}" class="w-full h-full object-cover object-center swiper-lazy">
                    <div class="swiper-lazy-preloader"></div>
                  </div>
            {{ /foreach:photos}}
        </div>
        <div class="swiper-pagination"></div>
        <div class="swiper-button-prev"></div>
        <div class="swiper-button-next"></div>
    </div>
</div>
Run Code Online (Sandbox Code Playgroud)

我的JS:

// core version + navigation, pagination modules:
import Swiper, { Navigation, Pagination } from 'swiper';
import 'swiper/swiper-bundle.css';

// configure Swiper to use modules
Swiper.use([Navigation, Pagination]);


var mySwiper = …
Run Code Online (Sandbox Code Playgroud)

statamic swiper.js

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