//url 图片路径
const xhr = new XMLHttpRequest();
xhr.open('GET', url)
xhr.responseType = 'blob'
xhr.send()
xhr.onload = function() {
const fileBlob = xhr.response;
const fileUrl = URL.createObjectURL(fileBlob)
const ele = document.createElement('a')
ele.setAttribute('href', fileUrl)
ele.setAttribute('download', "图片保存名称")
ele.click()
}
存本地图片完美,网络图片本次测试跨域不行,线上未测试