关于layer.photos调用问题

    <div class="photo-group" id='photo-list'>
        <img src="./pic/product22.jpg" layer-src="./pic/product22.jpg" alt="">
        <img src="./pic/product33.png" layer-src="./pic/product33.png" alt="">
        <img src="./pic/product44.jpg" layer-src="./pic/product44.jpg" alt="">
        <img src="./pic/product55.jpg" layer-src="./pic/product55.jpg" alt="">
    
    </div>
$('#photo-list img').on('click',function(){
    layer.photos({
        photos: '#photo-list',
        shadeClose:false,
        closeBtn:2,
        anim: 0 
    });
})

这是一组照片列表,现在的问题是第一次点击图片正常,关闭层后,第二次点击出来两个弹出层,第三次弹出三个,第四次四个以此类推(这不正常),这是怎么搞的,怎么让每次点击图片只有一个弹出层出来

阅读 10.7k
2 个回答

我不知道你这里的layer是什么东西,但是根据你的描述,你可以改成这样试试:

layer.photos({
    photos: '#photo-list',
    shadeClose:false,
    closeBtn:2,
    anim: 0 
});

就是删除事件绑定,可能这个组件内部已经帮你做了事件绑定。

layer.photos已经绑定好事件了,直接layer.photos({})就可以

撰写回答
你尚未登录,登录后可以
  • 和开发者交流问题的细节
  • 关注并接收问题和回答的更新提醒
  • 参与内容的编辑和改进,让解决方法与时俱进
推荐问题