{"id":3522,"date":"2024-11-10T11:13:01","date_gmt":"2024-11-10T03:13:01","guid":{"rendered":"https:\/\/fwq.ai\/blog\/3522\/"},"modified":"2024-11-10T11:13:01","modified_gmt":"2024-11-10T03:13:01","slug":"js%e4%b8%8a%e4%bc%a0%e5%a4%9a%e5%bc%a0%e5%9b%be%e7%89%87%e6%97%b6%ef%bc%8c%e5%a6%82%e4%bd%95%e8%8e%b7%e5%8f%96%e6%89%80%e6%9c%89%e5%9b%be%e7%89%87%e5%9c%b0%e5%9d%80%ef%bc%9f","status":"publish","type":"post","link":"https:\/\/fwq.ai\/blog\/3522\/","title":{"rendered":"JS\u4e0a\u4f20\u591a\u5f20\u56fe\u7247\u65f6\uff0c\u5982\u4f55\u83b7\u53d6\u6240\u6709\u56fe\u7247\u5730\u5740\uff1f"},"content":{"rendered":"<p><img decoding=\"async\" src=\"https:\/\/img.php.cn\/upload\/article\/001\/246\/273\/173105074454427.jpg\" class=\"aligncenter\" title=\"JS\u4e0a\u4f20\u591a\u5f20\u56fe\u7247\u65f6\uff0c\u5982\u4f55\u83b7\u53d6\u6240\u6709\u56fe\u7247\u5730\u5740\uff1f\u63d2\u56fe\" alt=\"JS\u4e0a\u4f20\u591a\u5f20\u56fe\u7247\u65f6\uff0c\u5982\u4f55\u83b7\u53d6\u6240\u6709\u56fe\u7247\u5730\u5740\uff1f\u63d2\u56fe\" \/><\/p>\n<p><strong>js\u4f20\u9012\u4e0a\u4f20\u56fe\u7247\u8def\u5f84\u6709\u70b9\u95ee\u9898\u8bf7\u6559\uff1f<\/strong><\/p>\n<p>\u672c\u95ee\u9898\u662f\u5173\u4e8e\u4e00\u4e2a\u56fe\u7247\u4e0a\u4f20\u811a\u672c\u7684\u95ee\u9898\uff0c\u5728\u4e0a\u4f20\u591a\u5f20\u56fe\u7247\u65f6\uff0c\u539f\u4ee3\u7801\u53ea\u80fd\u83b7\u53d6\u6700\u540e\u4e00\u5f20\u56fe\u7247\u7684\u5730\u5740\u3002<\/p>\n<p><strong>\u95ee\u9898\u8be6\u60c5<\/strong><\/p>\n<pre>    uploader.on('uploadSuccess', function(file,response) {\n        \/\/uploader.options.formData.data_type = 1;\n        \/\/alert(JSON.stringify(response.status));\/\/response\u662f\u8fd4\u56de\u7684json\u4e32 status\u662fjson\u4e2d\u7684\u5143\u7d20\n        $(\"#imgs_url\").append(JSON.stringify(response.imgurl)+\"&lt;\/br&gt;\");\/\/\u4e0a\u4f20\u540e\u8fd4\u56de\u7684\u56fe\u7247\u8def\u5f84\u8ffd\u52a0\u5230div\u4e2d\u53bb\n        var addtype3=$(\"#info3\").val(JSON.stringify(response.imgurl));\n    });<\/pre>\n<p>  \u767b\u5f55\u540e\u590d\u5236   <\/p>\n<p>\u539f\u4ee3\u7801\u5728\u4e0a\u4f20\u56fe\u7247\u6210\u529f\u540e\uff0c\u5c06\u56fe\u7247\u5730\u5740\u8ffd\u52a0\u5230 #imgs_url \u7684 div \u4e2d\uff0c\u5e76\u5c06\u503c\u8d4b\u7ed9 #info3 \u7684 input \u6846\u3002\u4f46\u8fd9\u79cd\u65b9\u5f0f\u4f1a\u5bfc\u81f4\u53ea\u80fd\u83b7\u53d6\u6700\u540e\u4e00\u5f20\u56fe\u7247\u7684\u5730\u5740\u3002<\/p>\n<p><strong>\u95ee\u9898\u89e3\u7b54<\/strong><\/p>\n<p>\u8981\u89e3\u51b3\u8fd9\u4e2a\u95ee\u9898\uff0c\u53ef\u4ee5\u4fee\u6539\u4ee3\u7801\u5982\u4e0b\uff1a<\/p>\n<pre>var imgUrls = [];\n\nuploader.on('uploadSuccess', function(file,response) {\n    $(\"#imgs_url\").append(JSON.stringify(response.imgurl)+\"&lt;\/br&gt;\");\n \n    imgUrls.push(JSON.stringify(response.imgurl));\n\n    $(\"#info3\").val(imgUrls.join(', '));\n});<\/pre>\n<p>  \u767b\u5f55\u540e\u590d\u5236   <\/p>\n<p>\u4fee\u6539\u5185\u5bb9\uff1a<\/p>\n<ul>\n<li>\u521b\u5efa\u4e00\u4e2a\u7a7a\u6570\u7ec4 imgUrls \u6765\u5b58\u50a8\u6240\u6709\u4e0a\u4f20\u56fe\u7247\u7684\u5730\u5740\u3002<\/li>\n<li>\u5728 uploadSuccess \u4e8b\u4ef6\u5904\u7406\u51fd\u6570\u4e2d\uff0c\u5c06\u8fd4\u56de\u7684\u56fe\u7247\u5730\u5740\u8ffd\u52a0\u5230 imgUrls \u6570\u7ec4\u4e2d\u3002<\/li>\n<li>\u6700\u540e\uff0c\u628a\u6240\u6709\u56fe\u7247\u5730\u5740\u7528 , \u4f5c\u4e3a\u5206\u9694\u7b26\uff0c\u62fc\u63a5\u6210\u4e00\u4e2a\u5b57\u7b26\u4e32\uff0c\u5e76\u8d4b\u503c\u7ed9 #info3\u3002<\/li>\n<\/ul>\n<p>\u8fd9\u6837\uff0c\u6bcf\u6b21\u4e0a\u4f20\u6210\u529f\u540e\uff0c\u90fd\u4f1a\u5c06\u56fe\u7247\u5730\u5740\u6dfb\u52a0\u5230 imgUrls \u6570\u7ec4\u4e2d\uff0c\u5e76\u6700\u7ec8\u5728 #info3 \u4e2d\u4fdd\u5b58\u6240\u6709\u4e0a\u4f20\u56fe\u7247\u7684\u5730\u5740\u3002<\/p>\n<p>\u4ee5\u4e0a\u5c31\u662fJS\u4e0a\u4f20\u591a\u5f20\u56fe\u7247\u65f6\uff0c\u5982\u4f55\u83b7\u53d6\u6240\u6709\u56fe\u7247\u5730\u5740\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>js\u4f20\u9012\u4e0a\u4f20\u56fe\u7247\u8def\u5f84\u6709\u70b9\u95ee\u9898\u8bf7\u6559\uff1f \u672c\u95ee\u9898\u662f\u5173\u4e8e\u4e00\u4e2a\u56fe\u7247\u4e0a\u4f20\u811a\u672c\u7684\u95ee\u9898\uff0c\u5728\u4e0a\u4f20\u591a\u5f20\u56fe\u7247\u65f6\uff0c\u539f\u4ee3\u7801\u53ea\u80fd\u83b7\u53d6\u6700\u540e\u4e00\u5f20\u56fe\u7247\u7684\u5730\u5740\u3002 \u95ee\u9898\u8be6\u60c5 uploader.on(&#8216;uploadSuccess&#8217;, function(file,response) { \/\/uploader.options.formData.data_type = 1; \/\/alert(JSON.stringify(response.status));\/\/response\u662f\u8fd4\u56de\u7684json\u4e32 status\u662fjson\u4e2d\u7684\u5143\u7d20 $(&#8220;#imgs_url&#8221;).append(JSON.stringify(response.imgurl)+&#8221;&lt;\/br&gt;&#8221;);\/\/\u4e0a\u4f20\u540e\u8fd4\u56de\u7684\u56fe\u7247\u8def\u5f84\u8ffd\u52a0\u5230div\u4e2d\u53bb var addtype3=$(&#8220;#info3&#8221;).val(JSON.stringify(response.imgurl)); }); \u767b\u5f55\u540e\u590d\u5236 \u539f\u4ee3\u7801\u5728\u4e0a\u4f20\u56fe\u7247\u6210\u529f\u540e\uff0c\u5c06\u56fe\u7247\u5730\u5740\u8ffd\u52a0\u5230 #imgs_url \u7684 div \u4e2d\uff0c\u5e76\u5c06\u503c\u8d4b\u7ed9 #info3 \u7684 input \u6846\u3002\u4f46\u8fd9\u79cd\u65b9\u5f0f\u4f1a\u5bfc\u81f4\u53ea\u80fd\u83b7\u53d6\u6700\u540e\u4e00\u5f20\u56fe\u7247\u7684\u5730\u5740\u3002 \u95ee\u9898\u89e3\u7b54 \u8981\u89e3\u51b3\u8fd9\u4e2a\u95ee\u9898\uff0c\u53ef\u4ee5\u4fee\u6539\u4ee3\u7801\u5982\u4e0b\uff1a var imgUrls = []; uploader.on(&#8216;uploadSuccess&#8217;, function(file,response) { $(&#8220;#imgs_url&#8221;).append(JSON.stringify(response.imgurl)+&#8221;&lt;\/br&gt;&#8221;); imgUrls.push(JSON.stringify(response.imgurl)); $(&#8220;#info3&#8221;).val(imgUrls.join(&#8216;, &#8216;)); }); \u767b\u5f55\u540e\u590d\u5236 \u4fee\u6539\u5185\u5bb9\uff1a \u521b\u5efa\u4e00\u4e2a\u7a7a\u6570\u7ec4 imgUrls \u6765\u5b58\u50a8\u6240\u6709\u4e0a\u4f20\u56fe\u7247\u7684\u5730\u5740\u3002 \u5728 uploadSuccess \u4e8b\u4ef6\u5904\u7406\u51fd\u6570\u4e2d\uff0c\u5c06\u8fd4\u56de\u7684\u56fe\u7247\u5730\u5740\u8ffd\u52a0\u5230 imgUrls \u6570\u7ec4\u4e2d\u3002 \u6700\u540e\uff0c\u628a\u6240\u6709\u56fe\u7247\u5730\u5740\u7528 , \u4f5c\u4e3a\u5206\u9694\u7b26\uff0c\u62fc\u63a5\u6210\u4e00\u4e2a\u5b57\u7b26\u4e32\uff0c\u5e76\u8d4b\u503c\u7ed9 #info3\u3002 \u8fd9\u6837\uff0c\u6bcf\u6b21\u4e0a\u4f20\u6210\u529f\u540e\uff0c\u90fd\u4f1a\u5c06\u56fe\u7247\u5730\u5740\u6dfb\u52a0\u5230 imgUrls [&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-3522","post","type-post","status-publish","format-standard","hentry","category-16"],"_links":{"self":[{"href":"https:\/\/fwq.ai\/blog\/wp-json\/wp\/v2\/posts\/3522","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=3522"}],"version-history":[{"count":0,"href":"https:\/\/fwq.ai\/blog\/wp-json\/wp\/v2\/posts\/3522\/revisions"}],"wp:attachment":[{"href":"https:\/\/fwq.ai\/blog\/wp-json\/wp\/v2\/media?parent=3522"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/fwq.ai\/blog\/wp-json\/wp\/v2\/categories?post=3522"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/fwq.ai\/blog\/wp-json\/wp\/v2\/tags?post=3522"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}