antd pro ProFormUploadButton上傳圖片獲取服務器返回信息


<ProFormUploadButton label="上傳憑證" max={1} name="file"  rules={[{ required: true, message: '請上傳到款憑證' }]}
  action="/api/common/uploadimage" //上傳圖片接口地址
  onChange={(e) => {
    if (e.file.status == 'removed') { //移除圖片時;
      SetVoucherImg('')
    } else if (e.file.status == 'done') { //上傳完成時
      if (e.file.response.Type == 200) {
        SetVoucherImg(e.file.response.Data)
      } else {
        message.error(e.file.response.Content ?? '上傳失敗')
      }
    } else if (e.file.status == 'error') { //上傳錯誤時
      message.error('上傳失敗')
    }
    //status狀態:'error' | 'success' | 'done' | 'uploading' | 'removed';   }}
/>

當狀態為done時,response為服務器返回數據

 


免責聲明!

本站轉載的文章為個人學習借鑒使用,本站對版權不負任何法律責任。如果侵犯了您的隱私權益,請聯系本站郵箱yoyou2525@163.com刪除。



 
粵ICP備18138465號   © 2018-2025 CODEPRJ.COM