{"id":2750,"date":"2024-11-10T11:16:41","date_gmt":"2024-11-10T03:16:41","guid":{"rendered":"https:\/\/fwq.ai\/blog\/2750\/"},"modified":"2024-11-10T11:16:41","modified_gmt":"2024-11-10T03:16:41","slug":"html2canvas-%e5%af%bc%e5%87%ba%e7%bd%91%e9%a1%b5%e4%b8%ba-pdf-%e6%97%b6%e9%81%87%e5%88%b0-element-not-found-%e9%97%ae%e9%a2%98%e5%a6%82%e4%bd%95%e8%a7%a3%e5%86%b3%ef%bc%9f","status":"publish","type":"post","link":"https:\/\/fwq.ai\/blog\/2750\/","title":{"rendered":"HTML2Canvas \u5bfc\u51fa\u7f51\u9875\u4e3a PDF \u65f6\u9047\u5230 Element Not Found \u95ee\u9898\u5982\u4f55\u89e3\u51b3\uff1f"},"content":{"rendered":"<p><img decoding=\"async\" src=\"https:\/\/img.php.cn\/upload\/article\/001\/246\/273\/173087120494165.jpg\" class=\"aligncenter\" title=\"HTML2Canvas \u5bfc\u51fa\u7f51\u9875\u4e3a PDF \u65f6\u9047\u5230 Element Not Found \u95ee\u9898\u5982\u4f55\u89e3\u51b3\uff1f\u63d2\u56fe\" alt=\"HTML2Canvas \u5bfc\u51fa\u7f51\u9875\u4e3a PDF \u65f6\u9047\u5230 Element Not Found \u95ee\u9898\u5982\u4f55\u89e3\u51b3\uff1f\u63d2\u56fe\" \/><\/p>\n<p><strong>\u5bfc\u51fa\u7f51\u9875\u4e3a pdf \u65f6\u9047\u5230 element not found \u95ee\u9898<\/strong><\/p>\n<p>\u5728\u4f7f\u7528 HTML2Canvas \u548c JsPDF \u5bfc\u51fa\u7f51\u9875\u4e3a PDF \u65f6\uff0c\u53ef\u80fd\u4f1a\u9047\u5230\u201cUncaught (in promise) Unable to find element in cloned iframe\u201d\u7684\u9519\u8bef\u3002\u8fd9\u662f\u56e0\u4e3a HTML2Canvas \u65e0\u6cd5\u5728\u514b\u9686\u7684 iframe \u4e2d\u627e\u5230\u8981\u5448\u73b0\u7684\u5143\u7d20\u3002<\/p>\n<p>\u89e3\u51b3\u65b9\u6848\u662f\u68c0\u67e5 HTML2Canvas \u7528\u4e8e\u521b\u5efa\u753b\u5e03\uff08canvas\uff09\u7684\u4ee3\u7801\u3002\u786e\u4fdd\u5143\u7d20\u6b63\u786e\u521b\u5efa\u5e76\u4e14\u5177\u6709\u552f\u4e00\u7684 ID\u3002<\/p>\n<p><strong>\u5e38\u89c1\u9519\u8bef\uff1a<\/strong><\/p>\n<p>\u7b2c\u4e00\u884c\u4ee3\u7801\u4e2d\u5b58\u5728\u62fc\u5199\u9519\u8bef\uff1a<\/p>\n<p><span>\u7acb\u5373\u5b66\u4e60<\/span>\u201c\u201d\uff1b<\/p>\n<pre>let div = document.createdElement('div');<\/pre>\n<p> \u767b\u5f55\u540e\u590d\u5236 <\/p>\n<p>\u6b63\u786e\u7684\u65b9\u5f0f\u662f\uff1a<\/p>\n<pre>let div = document.createElement('div');<\/pre>\n<p> \u767b\u5f55\u540e\u590d\u5236 <\/p>\n<p>\u4ee5\u4e0a\u5c31\u662fHTML2Canvas \u5bfc\u51fa\u7f51\u9875\u4e3a PDF \u65f6\u9047\u5230 Element Not Found \u95ee\u9898\u5982\u4f55\u89e3\u51b3\uff1f\u7684\u8be6\u7ec6\u5185\u5bb9\uff0c\u66f4\u591a\u8bf7\u5173\u6ce8\u7c73\u4e91\u5176\u5b83\u76f8\u5173\u6587\u7ae0\uff01<\/p>\n","protected":false},"excerpt":{"rendered":"<p>\u5bfc\u51fa\u7f51\u9875\u4e3a pdf \u65f6\u9047\u5230 element not found \u95ee\u9898 \u5728\u4f7f\u7528 HTML2Canvas \u548c JsPDF \u5bfc\u51fa\u7f51\u9875\u4e3a PDF \u65f6\uff0c\u53ef\u80fd\u4f1a\u9047\u5230\u201cUncaught (in promise) Unable to find element in cloned iframe\u201d\u7684\u9519\u8bef\u3002\u8fd9\u662f\u56e0\u4e3a HTML2Canvas \u65e0\u6cd5\u5728\u514b\u9686\u7684 iframe \u4e2d\u627e\u5230\u8981\u5448\u73b0\u7684\u5143\u7d20\u3002 \u89e3\u51b3\u65b9\u6848\u662f\u68c0\u67e5 HTML2Canvas \u7528\u4e8e\u521b\u5efa\u753b\u5e03\uff08canvas\uff09\u7684\u4ee3\u7801\u3002\u786e\u4fdd\u5143\u7d20\u6b63\u786e\u521b\u5efa\u5e76\u4e14\u5177\u6709\u552f\u4e00\u7684 ID\u3002 \u5e38\u89c1\u9519\u8bef\uff1a \u7b2c\u4e00\u884c\u4ee3\u7801\u4e2d\u5b58\u5728\u62fc\u5199\u9519\u8bef\uff1a \u7acb\u5373\u5b66\u4e60\u201c\u201d\uff1b let div = document.createdElement(&#8216;div&#8217;); \u767b\u5f55\u540e\u590d\u5236 \u6b63\u786e\u7684\u65b9\u5f0f\u662f\uff1a let div = document.createElement(&#8216;div&#8217;); \u767b\u5f55\u540e\u590d\u5236 \u4ee5\u4e0a\u5c31\u662fHTML2Canvas \u5bfc\u51fa\u7f51\u9875\u4e3a PDF \u65f6\u9047\u5230 Element Not Found \u95ee\u9898\u5982\u4f55\u89e3\u51b3\uff1f\u7684\u8be6\u7ec6\u5185\u5bb9\uff0c\u66f4\u591a\u8bf7\u5173\u6ce8\u7c73\u4e91\u5176\u5b83\u76f8\u5173\u6587\u7ae0\uff01<\/p>\n","protected":false},"author":1,"featured_media":0,"comment_status":"closed","ping_status":"","sticky":false,"template":"","format":"standard","meta":{"footnotes":""},"categories":[16],"tags":[],"class_list":["post-2750","post","type-post","status-publish","format-standard","hentry","category-16"],"_links":{"self":[{"href":"https:\/\/fwq.ai\/blog\/wp-json\/wp\/v2\/posts\/2750","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/fwq.ai\/blog\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/fwq.ai\/blog\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/fwq.ai\/blog\/wp-json\/wp\/v2\/users\/1"}],"replies":[{"embeddable":true,"href":"https:\/\/fwq.ai\/blog\/wp-json\/wp\/v2\/comments?post=2750"}],"version-history":[{"count":0,"href":"https:\/\/fwq.ai\/blog\/wp-json\/wp\/v2\/posts\/2750\/revisions"}],"wp:attachment":[{"href":"https:\/\/fwq.ai\/blog\/wp-json\/wp\/v2\/media?parent=2750"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/fwq.ai\/blog\/wp-json\/wp\/v2\/categories?post=2750"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/fwq.ai\/blog\/wp-json\/wp\/v2\/tags?post=2750"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}