问题描述
我在使用 Swup 进行页面转换时试图销毁并重新加载我的 Flickity 幻灯片,但我运气不佳。这是我的 js 文件:
import Swup from 'swup';
var Flickity = require('flickity');
function init() {
if (document.querySelector('.testimonials-slideshow')) {
var flkty = new Flickity('.testimonials-slideshow',{
wrapAround: true,pageDots: false,autoPlay: true,arrowShape: 'M68.374,83.866L31.902,50L68.374,16.134L64.814,12.3L24.214,50L64.814,87.7L68.374,83.866Z'
});
}
}
function unload() {
flkty.destroy();
}
init();
const swup = new Swup();
swup.on('contentReplaced',init);
swup.on('willReplaceContent',unload);
但是当我尝试这样做时,我收到错误 flkty is not defined
。任何人都可以给我任何指示吗?
解决方法
暂无找到可以解决该程序问题的有效方法,小编努力寻找整理中!
如果你已经找到好的解决方法,欢迎将解决方案带上本链接一起发送给小编。
小编邮箱:dio#foxmail.com (将#修改为@)