html52.com
我爱小程序-开发者交流社区

wx.request返回的是图片的二进制数据,如何用image控件将其显示出来?

同标题

网友回复

风云:

不行啊,发送的是获取小程序码的请求,我无法控制啊

wx.request({ //获取小程序码
          url: "https://api.weixin.qq.com/wxa/getwxacodeunlimit?access_token=" + getApp().globalData.access_token, //仅为示例,并非真实的接口地址
          header: {
            'content-type': 'application/json' // 默认值
          },
          data:{
            scene: json.content,
            page:"pages/news/detial",
            width:430
          },
          method:"POST",
          success: function (res) {
            var json = res.data;//获取的html文本信息
            console.log('小程序码:')
            console.log(res);
            // that.setData({img: json})
            wx.hideNavigationBarLoading();
          }
        })


娇华:

你好,还有一个办法就是可以让后端直接返回图片链接给你哈,(#^.^#)


解析:

var that=this;

wx.downloadFile({

    url:'**********'

    success:function(e){

        that.setData({

                imgPath:e.tempFilePath

        });

    }

})


<image src='{{imgPaht}}' />


这样不行吗?

评论 抢沙发

  • 昵称 (必填)
  • 邮箱 (必填)
  • 网址

真正的个人免签约支付接口

云免签H5支付