{"id":1042,"date":"2023-03-12T09:56:52","date_gmt":"2023-03-12T01:56:52","guid":{"rendered":"https:\/\/www.appblog.cn\/?p=1042"},"modified":"2023-04-29T12:41:38","modified_gmt":"2023-04-29T04:41:38","slug":"ant-design-upload-component","status":"publish","type":"post","link":"https:\/\/www.appblog.cn\/index.php\/2023\/03\/12\/ant-design-upload-component\/","title":{"rendered":"Ant Design Upload\u7ec4\u4ef6"},"content":{"rendered":"<p>\u6587\u6863\uff1a<a target=\"_blank\" rel=\"noopener\" href=\"https:\/\/3x.ant.design\/components\/upload-cn\/\">https:\/\/3x.ant.design\/components\/upload-cn\/<\/a><\/p>\n<h3>\u53d6\u6d88\u56fe\u7247\u5220\u9664\u6309\u94ae<\/h3>\n<pre><code class=\"language-javascript\">&lt;Upload\n  showUploadList={{showRemoveIcon:false}}  \/\/\u52a0\u4e0a\u8fd9\u53e5\u4ee3\u7801\n  onChange={this.uploadStateChange}\n  beforeUpload={this.beforeUpload}\n  listType=&quot;picture-card&quot;\n  fileList={this.state.fileList}\n  onRemove={this.handleRemove}\n  onPreview={this.handlePreview}\n  onSuccess={this.complate}\n><\/code><\/pre>\n<p><!-- more --><\/p>\n<h3>\u663e\u793a\u6587\u4ef6\u4e0b\u8f7d\u6309\u94ae<\/h3>\n<pre><code class=\"language-javascript\">const props = {\n  action: action,\n  headers: { Authorization: token },\n  data: { merchantId: merchant_id, fileType: type },\n  \/\/ customRequest: this.customRequest,\n  onChange: this.handleChange,\n  \/\/ beforeUpload: this.beforeUpload,\n  listType: &#039;picture&#039;,\n  multiple: true,\n  onRemove: this.onRemove,\n  onDownload: this.onDownload,\n  className: &#039;upload-list-inline&#039;,\n  showUploadList: { showDownloadIcon: true }\n  \/\/ defaultFileList: [...fileList],\n};<\/code><\/pre>\n<pre><code class=\"language-javascript\">{list.map((data, i) =&gt; (\n  &lt;div key={i} className={`${aStyle} ${bStyle} `}&gt;\n    &lt;Upload\n      key={i}\n      {...props}\n      defaultFileList={this.getDefaultUploadFile(type, data.doc_id)}\n      \/\/ fileList={this.getDefaultUploadFile(type, data.doc_id)}\n      \/\/ beforeUpload={file =&gt; this.beforeUpload(file, data.doc_id)}\n      handleChange={file =&gt; this.handleChange(file, data.doc_id)}\n    \/&gt;\n  &lt;\/div&gt;\n))}<\/code><\/pre>\n","protected":false},"excerpt":{"rendered":"<p>\u6587\u6863\uff1ahttps:\/\/3x.ant.design\/components\/upload-cn\/ \u53d6\u6d88\u56fe\u7247\u5220\u9664\u6309\u94ae [&hellip;]<\/p>\n","protected":false},"author":1,"featured_media":0,"comment_status":"open","ping_status":"open","sticky":false,"template":"","format":"standard","meta":{"footnotes":""},"categories":[288],"tags":[287],"class_list":["post-1042","post","type-post","status-publish","format-standard","hentry","category-ant-design","tag-antd"],"_links":{"self":[{"href":"https:\/\/www.appblog.cn\/index.php\/wp-json\/wp\/v2\/posts\/1042","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/www.appblog.cn\/index.php\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/www.appblog.cn\/index.php\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/www.appblog.cn\/index.php\/wp-json\/wp\/v2\/users\/1"}],"replies":[{"embeddable":true,"href":"https:\/\/www.appblog.cn\/index.php\/wp-json\/wp\/v2\/comments?post=1042"}],"version-history":[{"count":0,"href":"https:\/\/www.appblog.cn\/index.php\/wp-json\/wp\/v2\/posts\/1042\/revisions"}],"wp:attachment":[{"href":"https:\/\/www.appblog.cn\/index.php\/wp-json\/wp\/v2\/media?parent=1042"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/www.appblog.cn\/index.php\/wp-json\/wp\/v2\/categories?post=1042"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/www.appblog.cn\/index.php\/wp-json\/wp\/v2\/tags?post=1042"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}