getQRCode() {
var that = this;
wx.request({
url: 'http://localhost:8080/getQRCode?ID=' + '13',
header: {
'content-type': 'application/json'
},
method: 'POST',
responseType: 'arraybuffer',//将原本按文本解析修改为arraybuffer
success(res) {
that.setData({
getQRCode: wx.arrayBufferToBase64(res.data)
})
console.log(that.data.getQRCode1)
}
})
},
<button class="btn1" type="primary" bindtap="getQRCode">生成携带参数的二维码</button><!--绿色样式-->
<view>二维码:<image src="data:image/png;base64,{{getQRCode}}" style="width: 50vw; height: 20vh;"></image></view>
/**
* 页面的初始数据
*/
data: {
getQRCode: "",
},