收藏功能失效
来源:19-8 交互反馈 wx.showToast
TeamMeng
2018-05-29
按照老师的代码打的,但是每次点击收藏后退出文章详情页面后,再次回来文章详情页面,发现缓存是true,但是图片却是为收藏的
3回答
-
paohai
2018-09-03
onColletionTap: function (event) {
// this.getPostsCollectedSyc();
this.getPostsCollectedAsy();
},
getPostsCollectedAsy: function () {
var that = this;
wx.getStorage({
key: "posts_collected",
success: function (res) {
var postsCollected = res.data;
var postCollected = postsCollected[that.data.currentPostId];
// 收藏变成未收藏,未收藏变成收藏
postCollected = !postCollected;
postsCollected[that.data.currentPostId] = postCollected;
that.showToast(postsCollected, postCollected);
}
})
},
getPostsCollectedSyc: function () {
var postsCollected = wx.getStorageSync('posts_collected');
var postCollected = postsCollected[this.data.currentPostId];
// 收藏变成未收藏,未收藏变成收藏
postCollected = !postCollected;
postsCollected[this.data.currentPostId] = postCollected;
this.showToast(postsCollected, postCollected);
},
00 -
7七月
2018-05-29
可以到群里下载源码看看。这块是没有问题的。
012018-05-30 -
TeamMeng
提问者
2018-05-29
改正:缓存是true,但是图片是未收藏的
00
相似问题