在手机百度浏览器下载压缩后的图片,为什么下载不来,下载资源错误,大小未知,如何解决
const compressImage = async ({ width, height, url, name })=>{
// console.log(' width, height, url, name ',width, height, url, name);
fetch(url).then(res=>res.blob()).then(blob=>{
console.log('blob',blob);
new Compressor(blob,{
quality: 0.1,
width,
height,
success: (res) => {
console.log(res);
// 下载
const blobUrl = URL.createObjectURL(res)
const aDown = document.createElement('a')
aDown.download = name
aDown.style.display = 'none'
aDown.href = blobUrl
// 触发点击
document.body.appendChild(aDown)
aDown.click()
// 然后移除
document.body.removeChild(aDown)
},
error: (err) => {
console.log(err);
}
})
})
}