【发布时间】:2020-04-10 13:01:33
【问题描述】:
我在我的页面上使用 lightgallery,它工作正常。我已经为画廊添加了过滤功能,所以现在需要销毁并重建我的光画廊以反映画廊内容的变化。到目前为止我有这个:
source.js
import 'lightgallery.js';
var gallery = document.getElementById('gallerywrapper');
if(gallery) {
lightGallery(gallery, {
download: false,
counter: false,
selector: '.item.active'
});
}
var galleryFilterButtons = document.querySelectorAll('.gallery-filter-button');
for(var i = 0; i<galleryFilterButtons.length; i++) {
galleryFilterButtons[i].addEventListener("click", function(){
// destroy and rebuild here...
});
}
我根本无法使用destroy函数,谁能指点一下?
【问题讨论】: