4 回复
wx.request里面把responseType设成arraybuffer,然后成功之后wx.arrayBufferToBase64(res.data)转成base64。
getValidateCode:function(){
var that = this;
wx.request({
url: validateCodePath,
method:‘get’,
responseType: ‘arraybuffer’,
success:function(res){
const base64 = wx.arrayBufferToBase64(res.data);
that.setData({
validateCodePath: “data:image/png;base64,” + base64
});
}
})
}
不行啊,发送的是获取小程序码的请求,我无法控制啊
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(); } }) |