getImgase64 (list) {
const url = ''
const fetchRes = []
list.forEach(item => {
fetchRes.push(new Promise((resolve, reject) => {
fetch(url + item.imgId)
.then(response => response.blob())
.then(blob => {
// 将 Blob 对象转换为 Base64 字符串
return new Promise((resolve, reject) => {
const reader = new FileReader()
reader.onloadend = () => resolve(reader.result.split(',')[1])
reader.onerror = reject
reader.readAsDataURL(blob)
})
}).then(base64String => {
// 在这里可以使用 base64String 进行进一步处理
item.testImg = 'data:image/png;base64,' + base64String
const chartItem = this.chartData[item.imgIndex]
chartItem.imgBase64 = item.testImg
this.$set(this.chartData, item.imgIndex, chartItem)
resolve(item)
})
})
)
})
},