在初始化高德地图的时候配置 preserveDrawingBuffer:true
this.map = new AMap.Map("container", {
WebGLParams:{
preserveDrawingBuffer:true
}
});
html2canvas截图配置
html2canvas(document.getElementById("container"), {
backgroundColor: null,
border: null,
useCORS: true, // 如果截图的内容里有图片,可能会有跨域的情况,加上这个参数,解决文件跨域问题
}).then((canvas) => {
let url = canvas.toDataURL("image/png", 1);
});
},