getBase64(url, callback) {
var Img = new Image(),
dataURL = "";
Img.src = url + "?v=" + Math.random();
Img.setAttribute("crossOrigin", "Anonymous");
Img.onload = function () {
var canvas = document.createElement("canvas"),
width = Img.width,
height = Img.height;
canvas.width = width;
canvas.height = height;
canvas.getContext("2d").drawImage(Img, 0, 0, width, height);
dataURL = canvas.toDataURL("image/jpeg");
callback ? callback(dataURL) : null;
};
}
vue 图片url转Base64编码
最新推荐文章于 2025-03-31 18:28:58 发布