{"id":1394,"date":"2024-11-10T15:22:56","date_gmt":"2024-11-10T07:22:56","guid":{"rendered":"https:\/\/fwq.ai\/blog\/1394\/"},"modified":"2024-11-10T15:22:56","modified_gmt":"2024-11-10T07:22:56","slug":"%e5%a6%82%e4%bd%95%e4%bd%bf%e7%94%a8-blob-url-%e5%9c%a8-b-%e7%ab%99%e4%b8%bb%e9%a1%b5%e9%a1%b6%e9%83%a8%e6%a8%aa%e5%b9%85%e4%b8%8a%e5%88%9b%e5%bb%ba%e6%8c%87%e5%90%91%e5%9b%be%e5%83%8f%e5%89%af","status":"publish","type":"post","link":"https:\/\/fwq.ai\/blog\/1394\/","title":{"rendered":"\u5982\u4f55\u4f7f\u7528 Blob URL \u5728 B \u7ad9\u4e3b\u9875\u9876\u90e8\u6a2a\u5e45\u4e0a\u521b\u5efa\u6307\u5411\u56fe\u50cf\u526f\u672c\u7684\u94fe\u63a5\uff1f"},"content":{"rendered":"<p><img decoding=\"async\" src=\"https:\/\/img.php.cn\/upload\/article\/001\/246\/273\/173042085915899.jpg\" class=\"aligncenter\" title=\"\u5982\u4f55\u4f7f\u7528 Blob URL \u5728 B \u7ad9\u4e3b\u9875\u9876\u90e8\u6a2a\u5e45\u4e0a\u521b\u5efa\u6307\u5411\u56fe\u50cf\u526f\u672c\u7684\u94fe\u63a5\uff1f\u63d2\u56fe\" alt=\"\u5982\u4f55\u4f7f\u7528 Blob URL \u5728 B \u7ad9\u4e3b\u9875\u9876\u90e8\u6a2a\u5e45\u4e0a\u521b\u5efa\u6307\u5411\u56fe\u50cf\u526f\u672c\u7684\u94fe\u63a5\uff1f\u63d2\u56fe\" \/><\/p>\n<p><strong>\u5982\u4f55\u5236\u4f5c b\u7ad9\u4e3b\u9875\u9876\u90e8\u6a2a\u5e45\u4e0a\u7684 blob:\u94fe\u63a5<\/strong><\/p>\n<p>\u95ee\u9898\u4e2d\u63d0\u5230\u7684 blob:\u94fe\u63a5\u662f\u4e00\u79cd\u7531 URL.createObjectURL \u63a5\u53e3\u521b\u5efa\u7684 Blob URL\u3002\u4e0e\u76f4\u63a5\u8bbf\u95ee\u6587\u4ef6 URL \u4e0d\u540c\uff0cBlob URL \u6307\u5411\u670d\u52a1\u5668\u4e0a\u7684\u6587\u4ef6\u5185\u5bb9\u526f\u672c\uff0c\u8be5\u526f\u672c\u5b58\u50a8\u5728\u6d4f\u89c8\u5668\u4e2d\u3002<\/p>\n<p><strong>\u521b\u5efa Blob URL \u7684\u6b65\u9aa4\uff1a<\/strong><\/p>\n<ol>\n<li> <strong>\u521b\u5efa Blobs\uff1a<\/strong> \u4f7f\u7528 FileReader \u6216 Fetch API \u8bfb\u53d6\u6587\u4ef6\u6216\u4ece BlobBuilder \u521b\u5efa Blobs\u3002<\/li>\n<li> <strong>\u8c03\u7528 createObjectURL\uff1a<\/strong>\u4f7f\u7528 URL.createObjectURL \u65b9\u6cd5\u5c06 Blob \u8f6c\u6362\u4e3a Blob URL\u3002<\/li>\n<\/ol>\n<p><strong>\u793a\u4f8b\uff1a<\/strong><\/p>\n<pre>\/\/ \u521b\u5efa\u4e00\u4e2aBlob\nconst blob = new Blob(['Hello World!']);\n\n\/\/ \u521b\u5efaBlob URL\nconst blobUrl = URL.createObjectURL(blob);<\/pre>\n<p>  \u767b\u5f55\u540e\u590d\u5236   <\/p>\n<p>\u6ce8\u610f\uff1aBlob URL \u5728\u521b\u5efa\u540e\u4e0d\u80fd\u4fee\u6539\uff0c\u5e76\u4e14\u5f53\u4e0d\u518d\u9700\u8981\u65f6\u5fc5\u987b\u91ca\u653e\u3002\u53ef\u4ee5\u901a\u8fc7\u8c03\u7528 URL.revokeObjectURL \u65b9\u6cd5\u6765\u91ca\u653e Blob URL\u3002<\/p>\n<p><strong>\u5e94\u7528\u5230 B\u7ad9\u4e3b\u9875\u9876\u90e8\u6a2a\u5e45\uff1a<\/strong><\/p>\n<p>\u867d\u7136\u672c\u6587\u6863\u65e0\u6cd5\u63d0\u4f9b B\u7ad9\u5177\u4f53\u5b9e\u73b0\u7ec6\u8282\uff0c\u4f46\u60a8\u53ef\u4ee5\u5c1d\u8bd5\u4f7f\u7528\u4ee5\u4e0b\u901a\u7528\u65b9\u6cd5\uff1a<\/p>\n<ol>\n<li>\u4f7f\u7528 JavaScript \u4ee3\u7801\u6355\u83b7\u8981\u4e0b\u8f7d\u7684\u6a2a\u5e45\u56fe\u50cf\u3002<\/li>\n<li>\u5c06\u56fe\u50cf\u8f6c\u6362\u4e3a Blob\u3002<\/li>\n<li>\u8c03\u7528 createObjectURL \u521b\u5efa Blob URL\u3002<\/li>\n<li>\u5c06 Blob URL \u4fdd\u5b58\u5230\u9002\u5f53\u7684\u4f4d\u7f6e\uff08\u4f8b\u5982\uff0c\u8d85\u94fe\u63a5\u6216\u56fe\u50cf\u6e90\uff09\u3002<\/li>\n<\/ol>\n<p>\u8fd9\u6837\uff0c\u60a8\u5c31\u53ef\u4ee5\u521b\u5efa\u6307\u5411 B\u7ad9\u4e3b\u9875\u9876\u90e8\u6a2a\u5e45\u56fe\u50cf\u526f\u672c\u7684 blob:\u94fe\u63a5\u3002<\/p>\n<p>\u4ee5\u4e0a\u5c31\u662f\u5982\u4f55\u4f7f\u7528 Blob URL \u5728 B \u7ad9\u4e3b\u9875\u9876\u90e8\u6a2a\u5e45\u4e0a\u521b\u5efa\u6307\u5411\u56fe\u50cf\u526f\u672c\u7684\u94fe\u63a5\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>\u5982\u4f55\u5236\u4f5c b\u7ad9\u4e3b\u9875\u9876\u90e8\u6a2a\u5e45\u4e0a\u7684 blob:\u94fe\u63a5 \u95ee\u9898\u4e2d\u63d0\u5230\u7684 blob:\u94fe\u63a5\u662f\u4e00\u79cd\u7531 URL.createObjectURL \u63a5\u53e3\u521b\u5efa\u7684 Blob URL\u3002\u4e0e\u76f4\u63a5\u8bbf\u95ee\u6587\u4ef6 URL \u4e0d\u540c\uff0cBlob URL \u6307\u5411\u670d\u52a1\u5668\u4e0a\u7684\u6587\u4ef6\u5185\u5bb9\u526f\u672c\uff0c\u8be5\u526f\u672c\u5b58\u50a8\u5728\u6d4f\u89c8\u5668\u4e2d\u3002 \u521b\u5efa Blob URL \u7684\u6b65\u9aa4\uff1a \u521b\u5efa Blobs\uff1a \u4f7f\u7528 FileReader \u6216 Fetch API \u8bfb\u53d6\u6587\u4ef6\u6216\u4ece BlobBuilder \u521b\u5efa Blobs\u3002 \u8c03\u7528 createObjectURL\uff1a\u4f7f\u7528 URL.createObjectURL \u65b9\u6cd5\u5c06 Blob \u8f6c\u6362\u4e3a Blob URL\u3002 \u793a\u4f8b\uff1a \/\/ \u521b\u5efa\u4e00\u4e2aBlob const blob = new Blob([&#8216;Hello World!&#8217;]); \/\/ \u521b\u5efaBlob URL const blobUrl = URL.createObjectURL(blob); \u767b\u5f55\u540e\u590d\u5236 \u6ce8\u610f\uff1aBlob URL [&hellip;]<\/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-1394","post","type-post","status-publish","format-standard","hentry","category-16"],"_links":{"self":[{"href":"https:\/\/fwq.ai\/blog\/wp-json\/wp\/v2\/posts\/1394","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=1394"}],"version-history":[{"count":0,"href":"https:\/\/fwq.ai\/blog\/wp-json\/wp\/v2\/posts\/1394\/revisions"}],"wp:attachment":[{"href":"https:\/\/fwq.ai\/blog\/wp-json\/wp\/v2\/media?parent=1394"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/fwq.ai\/blog\/wp-json\/wp\/v2\/categories?post=1394"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/fwq.ai\/blog\/wp-json\/wp\/v2\/tags?post=1394"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}