/**
* 图片地址转图片文件
* @param imgUrl 图片地址
* **/
window.url2img = function (imgUrl){
let filename = new URL(imgUrl).pathname.split('/').pop();
let mimeType = imgUrl.split('.').pop()
return (fetch(imgUrl)
.then(function (res) { return res.arrayBuffer(); })
.then(function (buf) { return new File([buf], filename, { type: mimeType }); })
);
}
//使用
let t = 'https://img.guanhai.com.cn/a/10001/202007/c5d1c8882e991a48bf0fb6db27db953e.png?201504091823';
let b = url2img(t).then((res)=>{
console.log('b', res);
});