js图片下载


var url = 'https://ss0.bdstatic.com/70cFvHSh_Q1YnxGkpoWK1HF6hhy/it/u=743446847,1016653021&fm=27&gp=0.jpg'
// 将链接地址字符内容转变成blob地址
fetch( url). then( res => res. blob()). then( blob =>
// 创建隐藏的可下载链接   
var a = document. createElement( 'a');
a. style. display = 'none';
a. href = URL. createObjectURL( blob);       
a. download = 'QRcode.jpg';
document. body. appendChild( a);
a. click();
//移除元素
document. body. removeChild( a);
});

你可能感兴趣的:(备忘录)