getBase64(imgUrl) {
let _this = this
var xhr = new XMLHttpRequest()
xhr.open('get', imgUrl, true)
xhr.responseType = 'blob'
xhr.onload = function() {
if (this.status == 200) {
var blob = this.response
let oFileReader = new FileReader()
oFileReader.onloadend = function(e) {
// e.target.result为转换后的base64
_this.form.voucherImg = e.target.result
}
oFileReader.readAsDataURL(blob)
}
}
xhr.send()
},
网络图片url转base64
猜你喜欢
转载自blog.csdn.net/weixin_39818813/article/details/121790052
今日推荐
周排行