你是不是包括你的整個代碼,但如果我是以此來猜測這將是該變量使用的.next()函數O n不存在或者啓動錯誤。
試試這個:
var gallery; //As a global variable
//then when you init the gallery just use that same variable
//for instance
function OpenPhotoSwipe() {
var pswpElement = document.querySelectorAll('.pswp')[0];
var items = [{
src:'',
w:1,
h:1
}]
var options = { modal:false,bgOpacity:0.7 };
gallery = new PhotoSwipe(pswpElement, PhotoSwipeUI_Default, items, options);
gallery.init();
}
//And then finally use setInterval to queue the transition
setInterval(function() {
gallery.next();
},3000);
希望這有助於
我覺得一個人好解釋指鏈接http://stackoverflow.com/questions/27841324/photoswipe-is-there-a-way-to -attach-AN-事件處理程序至所述-INIT-事件或-WHE –