4
我有下面的代碼段的問題:未捕獲TypeMismatchError:未能執行上「的drawImage 'CanvasRenderingContext2D'
var o = $("#inserted_motive").find("span");
$.contains(document.documentElement, o[0]) ? b.fillText(m, i, h) : b.drawImage(d, i, 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, 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;
謝謝,它讓我的腳本工作。 – misterzik