1、http://html2canvas.hertzen.com/features/
转自 https://www.cnblogs.com/zhangdiIT/p/7895903.html
第三种根据自己所需稍微修改的版本:
urlToBase64(imgUrl){
let _this = this;
var image = new Image();
image.setAttribute('crossOrigin', 'anonymous');
image.src = imgUrl + "?v=" + new Date().getTime();
image.onload =function (){
_this.getBase64Image(image);
}
getBase64Image(img,width,height) {//width、height调用时传入具体像素值,控制大小 ,不传则默认图像大小
var canvas = document.createElement("canvas");
canvas.width = width ? width : img.width;
canvas.height = height ? height : img.height;
var ctx = canvas.getContext("2d");
ctx.drawImage(img, 0, 0, canvas.width, canvas.height);
var dataURL = canvas.toDataURL();
this.testImg = dataURL;
}