@a417420427/use-upload 中文文档教程

发布于 3年前 浏览 24 项目主页 更新于 3年前

an react hook of upload

usage

add file or files

import { useUpload } from '@a417420427/use-upload';
const { uploadFiles, uploadingFile, percent, uploadActions } = useUpload();
uploadActions.addUploadFiles(file);

set request config

// return an AxiosRequestConfig
const onBeforeUpload = (file: UploadFile): AxiosRequestConfig => {
  return {
    url: 'requestUrl',
  };
};
const { uploadActions } = useUpload({
  onBeforeUpload,
});

on file uploaded

const onFileUploaded = (file: UploadFile, files: UploadFile[]) => {
  console.log(file.uploadedStatus, file.target);
};
const { uploadActions } = useUpload({
  onFileUploaded,
});
uploadActions.addUploadFiles(file);

an react hook of upload

usage

add file or files

import { useUpload } from '@a417420427/use-upload';
const { uploadFiles, uploadingFile, percent, uploadActions } = useUpload();
uploadActions.addUploadFiles(file);

set request config

// return an AxiosRequestConfig
const onBeforeUpload = (file: UploadFile): AxiosRequestConfig => {
  return {
    url: 'requestUrl',
  };
};
const { uploadActions } = useUpload({
  onBeforeUpload,
});

on file uploaded

const onFileUploaded = (file: UploadFile, files: UploadFile[]) => {
  console.log(file.uploadedStatus, file.target);
};
const { uploadActions } = useUpload({
  onFileUploaded,
});
uploadActions.addUploadFiles(file);
    我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
    原文