慕哥6287543
123456789 window.onload = function () { var ctx = document.getElementById("canvas").getContext('2d'); var svg_xml = (new XMLSerializer()).serializeToString(document.getElementById("svg")); var img = new Image(); img.src = "data:image/svg+xml;base64," + window.btoa(svg_xml); img.onload = function () { ctx.drawImage(img, 0, 0); }; }ctx和svg_xml分别为canvas和svg对象;最后采取base64方式