P粉5216974192023-08-27 16:46:54
Yes, you can!
After the image responds, pass the image to URL.createObjectURL()
(Documentation). This will cache the image in the browser and provide a local image URL that you can reuse:
const imageUrl: string = URL.createObjectURL(response.data); if (imageUrl) { // 使用以下对象更新您的存储: { id: imageId, url: imageUrl }; }
You can then search by id
in the imageUrl[]
state where this URL is saved and retrieve the URL again.