getBase64();得到圖片路徑

玖捌發表於2024-03-20
  type FileType = Parameters<GetProp<UploadProps, 'beforeUpload'>>[0];

  const getBase64 = (img: FileType, callback: (url: string) => void) => {
    const reader = new FileReader();
    reader.addEventListener('load', () => callback(reader.result as string));
    reader.readAsDataURL(img);
  };
getBase64(file.originFileObj as FileType, (url) => {
       console.log(url)
  });

  

相關文章