时间:2021-07-01 10:21:17 帮助过:9人阅读
function getBase64Image(img) {
var canvas = document.createElement("canvas");
canvas.width = img.width;
canvas.height = img.height;
var ctx = canvas.getContext("2d");
ctx.drawImage(img, 0, 0);
var dataURL = canvas.toDataURL("image/png");
return dataURL.replace(/^data:image\/(png|jpg);base64,/, "");
}
document.querySelectorAll('img')
大概类似于document.getELementById('cool').onload=function(){//具体操作};