直接微信接口获取
wx.request({
url: 'https://api.weixin.qq.com/wxa/getwxacodeunlimit?access_token=' + this.data.access_token,
method: 'post',
ResponseType: 'arraybuffer',
header: {
"Content-Type": "application/json;charset-utf-8"
},
data: {
env_version: "trial", //测试版的意思
scene: "11111", //测试传输的数据
path: "pages/login/login",
width: 200,
},
success: function (res) {
console.log('小程序码', res.data)
const base64 = wx.arrayBufferToBase64(res.data)
that.setData({
imgurl: "data:image/png;base64," + base64
})
console.log('转换后', base64)
}
})
---------------------------------------------------
返回的值是乱码,是不是二进制?但wx.arrayBufferToBase64(res.data)转成图片,是空的 输出 base64 是空值