savePicture(base64) {
// var arr = base64.split(','); //可以这样去掉data:image/png;base64,只拿,号后面部分
var bytes = atob(base64)
let ab = new ArrayBuffer(bytes.length);
console.log(ab)
let ia = new Uint8Array(ab);
for (let i = 0; i < bytes.length; i++) {
ia[i] = bytes.charCodeAt(i);
}
var blob = new Blob([ab], { type: 'application/octet-stream' });
var url = URL.createObjectURL(blob);
var a = document.createElement('a');
a.href = url;
a.download = new Date().valueOf() + ".jpg";
var e = document.createEvent('MouseEvents');
e.initMouseEvent('click', true, false, window, 0, 0, 0, 0, 0, false, false, false, false, 0, null);
a.dispatchEvent(e);
URL.revokeObjectURL(url);
},
发表评论 取消回复