`

微信图片预览JS遇到的坑

阅读更多

微信图片预览遇到的一些问题总结:

1,图片路径要绝对路径,否则点击时,显示的是大图是第一张图。而不是点击的图片。

2,网站加载是http或https,jweixin-1.0.0.js的加载要对应起来。

<script src="https://res.wx.qq.com/open/js/jweixin-1.2.0.js?v=1"></script>

<script src="http://res.wx.qq.com/open/js/jweixin-1.2.0.js?v=1"></script>

 

 

 

 

 

                        $('.sccn-list-imgs li').unbind('click');
                        $('.sccn-list-imgs li').click(function(){
                            var baseUrl = document.location.protocol + '//'+location.host;
                            var id = $(this).attr('id');
                            var srcList = [];
                            var curSrc = baseUrl + $(this).find('img').attr('src');
                            //console.log(curSrc);
                            $.each($('.list_pic_'+id),function(i,item){
                               if(item.src) {
                                   srcList.push(baseUrl + $(this).attr('src'));
                               }
                            });
                            wx.previewImage({
                                current: curSrc, // 当前显示图片的http链接
                                urls: srcList // 需要预览的图片http链接列表
                            });
                        });

 

分享到:
评论

相关推荐

Global site tag (gtag.js) - Google Analytics