Home  >  Q&A  >  body text

javascript - Why can't I preview after taking a photo with WeChat jssdk?

When calling the WeChat interface chooseimg, in the successful callback function, according to WeChat, each ID in the local ID list of the selected photo is taken out and used as the src of the displayed image, but in fact all the IDs It has been returned, but after putting it in html, the picture cannot be displayed

wx.chooseImage({
  count: 1,
  sizeType: ['original', 'compressed'],
  sourceType: ['camera'],
  success: function (res) {
    var localId = res.localIds;
    $.each(res.localIds,function(i,n){
      $("#pic").append('<img src='+ n + '/>');
    })
}

The above is the code I wrote, but the picture cannot be found in which p of the pic

黄舟黄舟2685 days ago651

reply all(1)I'll reply

  • 我想大声告诉你

    我想大声告诉你2017-05-19 10:37:02

    It has been solved. It seems to be due to the latest browser of ios. I haven’t looked at the details. You need to use a getlocalimgdata API. In order to be compatible with Android and Apple, you also check whether the converted text in base64 format is correct. That’s it (this is my first self-question and answer, if there is anything unclear or wrong, please point it out)

    reply
    0
  • Cancelreply