微信jssdk接口得到的图片显示问题

这几天研究了一下这个微信公众平台的开发的问题
在使用chooseImage接口调用获取到了图片的时候一直显示不出来,百度了一些帖子结果都不是很好,后来终于研究出来怎么显示出来了,现在写出来做一个备份

使用微信JSDK的时候遇到的一些问题
在配置S接口安全域名的时候需要用一级域名,不能使用二级域名,并且不能带http 或者https
如我的测试上传图片网址是

applinzi.com


//html里的主要代码
<body ontouchstart=>
 上传图片的测试
 图像接口
      <span class=desc>拍照或从手机相册中选图接口</span>
      <button class=btn btn_primary id=chooseImage onclick=chooseImg_Opinion()>chooseImage</button>
    <span>图片预览</span>
    <p id=photo></p>
</body>

//js里的主要代码
<script>
    wx.ready(function () {
        //自动执行的
        wx.checkJsApi({
            jsApiList: [
                'chooseImage',
            ],
            success: function (res) {
                // alert(JSON.stringify(res));
                // alert(JSON.stringify(res.checkResult.getLocation));
                // if (res.checkResult.getLocation == false) {
                    // alert('你的微信版本太低,不支持微信JS接口,请升级到最新的微信版本!');
                    // return;
                // }
            }
        });
    });
    wx.error(function (res) {
        alert(res.errMsg);
    });
 function chooseImg_Opinion() {
                wx.chooseImage({
                    success: function (res) {
                        showImgs_Opinion(res);
                    }
                });
            }
 function showImgs_Opinion(res) {
//主要是这一块的代码
     var parent = document.getElementById('photo');
     var p = document.createElement(p);
    //设置 p 属性,如 id
    p.setAttribute(id, imgp);
     var _html=;
    for(var i in res.localIds){
           var photoSrc=res.localIds[i];
           _html=_html+'
图片'+i+':<img src='+photoSrc+' height=200 width=200 />\n';
    }
  p.innerHTML = _html;
  parent.appendChild(p);
 </script>

相关文章

网页授权获取用户信息的方法
报错config:invalid signature的解决方案
微信开发百思不得姐实战教程
详解微信开发input输入框
教你libco是如何支撑巨大数据信息量的
微信二次开发之文本消息请求与发送