我遇到以下代码段的问题:
var o = $("#inserted_motive").find("span"); $.contains(document.documentElement,o[0]) ? b.fillText(m,i,h) : b.drawImage(d,h,e,f); var p = a.toDataURL("image/png"); window.open(p) }),$(function () { $("#tabs").tabs() });
出现以下错误:
Uncaught TypeMismatchError: Failed to execute ‘drawImage’ on ‘CanvasRenderingContext2D’: The 1st argument provided is either null,or an invalid HTMLImageElement,HTMLCanvasElement or HTMLVideoElement object.
也回答了这个问题;
$("#creator").click(function () { var a = document.getElementById("final_image"),b = a.getContext("2d"),c = document.getElementById("shirt_main_canvas"),d = document.getElementById("inserted_image"); b.drawImage(c,0); var e = $("#inserted_image").width(),f = $("#inserted_image").height(),g = $("#inserted_motive").position(),h = g.top,i = g.left,j = $("#inserted_motive span").css("font-size"),k = $("#inserted_motive span").css("font-family"),l = $("#inserted_motive span").css("color"),m = $("#inserted_motive span").text(),n = j + " " + k;