ant design (antd) Upload 點擊上傳圖片反應過慢

每次點擊上傳的時候,要等半年,才能出來選擇文件框,有的時候,還會出來倆次,比較噁心,其實是電腦去本地搜索文件啥的,過濾的時間


const props = {
    action: this.state.action,
    fileList: fileList,
    data: {
        appid: appid,
        secret: secret,
    },
    headers: {'X-Requested-With': null},
    // accept: "image/*",
    accept: "image/jpg,image/jpeg,image/png,image/bmp",
    onChange: this.handleChange,
    beforeUpload: this.beforeUpload,
    onPreview: this.handlePreview,
    listType: "picture-card",
};


<Upload {...props}>
    {fileList.length >= this.state.length ? null : uploadButton}
</Upload>

注意點:

  • 重要的是上面註釋掉的:accept:想象一下,你如果給電腦很多篩選條件的話自然就慢了,image/*代表了全部的圖片文件,如果可能的話,儘量少寫兩個。速度自然就快了。
  • 不過第一次好像還是會慢點的,不過不會像以前一樣,每次都要等。
發表評論
所有評論
還沒有人評論,想成為第一個評論的人麼? 請在上方評論欄輸入並且點擊發布.
相關文章