getBase64=(val)=>{
const _this=this
window.URL = window.URL || window.webkitURL;
const xhr = new XMLHttpRequest();
xhr.open("get", val, true);
xhr.responseType = "blob";
xhr.onload = function () {
if (this.status == 200) {
const blob = this.response;
_this.createImg(blob,val)
}
}
xhr.send();
}
createImg=(params,url)=> {
const name=url.match(/com\/(\S*)\?/)[1]
const fileName = `${name}.jpg`
const elink =document.createElement('a');
elink.download=fileName
elink.style.display='none'
elink.href = URL.createObjectURL(params);
document.body.appendChild(elink);
elink.click();
URL.revokeObjectURL(elink.href); // 释放URL 对象
document.body.removeChild(elink);
}