Photoswipe无法阅读物业' center'在photoswipe.js的第1070行未定义

时间:2015-01-11 04:43:07

标签: javascript image exception gallery photoswipe

我只是在尝试使用photoswipe,到目前为止,我还没有做过任何比仅使用一些非常小的(以及理论上无关紧要的调整)实现入门演示的副本更先进的东西。

我的图片库很好,我总共有4个项目,因为我只是想测试一下。第一张照片将变焦和平移,所有这些都很棒。但是,当我切换图片时,我在这个帖子标题中得到了javascript错误。

我使用以下内容作为我的项目:

var items =[{"src":"/Images/Portfolio/Pieces/PhoenixFury.jpg","thumbnail":"/Images/Portfolio/Thumbs/PhoenixFury.jpg","msrc":"/Images/Portfolio/Thumbs/PhoenixFury.jpg","w":765,"h":1201,"title":"Phoenix\u0027s Fury","caption":"Illustration used for the cover of Lifeweaver","key":"Phoenix"},{"src":"/Images/Portfolio/Pieces/EnoreTower.jpg","thumbnail":"/Images/Portfolio/Thumbs/EnoreTower.jpg","msrc":"/Images/Portfolio/Thumbs/EnoreTower.jpg","w":765,"h":1200,"title":"Enore\u0027s Tower","caption":"Illustration used for the cover of Guardian\u0027s Peril","key":"Enore"},{"src":"/Images/Portfolio/Pieces/KenpoLogo.jpg","thumbnail":"/Images/Portfolio/Thumbs/KenpoLogo.jpg","msrc":"/Images/Portfolio/Thumbs/KenpoLogo.jpg","w":800,"h":966,"title":"Kenpo Karate Logo","caption":"Commissioned karate team logo for a team in Mexico with central american themes on the traditional Kenpo notion of a dragon and a tiger.","key":"Kenpo"},{"src":"/Images/Portfolio/Pieces/Quetzalcoatl.jpg","thumbnail":"/Images/Portfolio/Thumbs/Quetzalcoatl.jpg","msrc":"/Images/Portfolio/Thumbs/Quetzalcoatl.jpg","w":1600,"h":967,"title":"Quetzalcoatl","caption":"Central American ancient deity Quetzalcoatl, the feathered serpent.","key":"Quetzalcoatl"}];

我添加了一些自定义属性,但我还没有对photoswipe做任何事情来尝试使用它们,所以我不认为这是问题。

我使用以下作为我的选择:

        var options = {

            history: false,
            focus: false,
            index: 0,//I can verify that 0,1,2,3 all load up correctly for an initial load
            showAnimationDuration: 0,
            hideAnimationDuration: 0

        };

那么我就是这样做的:

   var photoswipe = new PhotoSwipe(pswpElement, PhotoSwipeUI_Default, items, options);
        photoswipe.init();

我有pswpElement,只是从photoswipe网站上删除了标记,所以它也应该排成一行。我真的很想知道我需要做些什么才能使它在换成新图像时能够正常工作。

我还验证了如果我从标题中删除了u207(编码'),它就不能解决问题只是为了试图彻底解决问题。

1 个答案:

答案 0 :(得分:8)

确保index选项值是整数,而不是字符串。 parseInt( ... , 10)