【发布时间】:2019-05-07 20:14:06
【问题描述】:
我的网站上有一个编辑个人资料的功能,我必须在其中更改个人资料图片。它已更改,但在页面刷新时,恢复为旧的个人资料图片。为了解决这个问题,我试图将它存储在 localforage 中。问题是,它没有存储在 localforage 中,并且在刷新时,图片恢复为旧图片。 如何在 localforage 中正确存储图像(或其 URL,以适当者为准)?
我试过这样存储它:
const { profilePic } = this.props;
localforage.getItem('currentUser').then((currentUser) => {
currentUser.profile_pic.url = profilePic;
localforage.setItem('currentUser',currentUser);
});
其中 currentUser 如下所示:
我希望将新上传的图片保存在 localforage 中。现在它没有正确存储在 localforage 中。
【问题讨论】:
标签: reactjs localforage