6-6 显示错误 请老师答疑 感谢 我在群647992970中...
来源:19-7 使用缓存实现文章收藏功能
Madao大仁
2018-03-21
onLoad: function (options) {
var postId = options.id;
this.setData({
CurrentpostId: postId
});
var postData = postsData.postlist[postId];
this.setData({
postData: postData
});
var postscollected = wx.getStorageSync('post_collecting');
var postcollected = postscollected[postId];
if (postscollected) {
if (postcollected) {
this.setData({
collected: postcollected
});
}
}
else {
var postscollected = {};
postscollected[postId] = false;
wx.setStorageSync('post_collecting', postscollected);
}
},
oncollectionTap: function (event) {
var postscollected = wx.getStorageSync('post_collecting');
var postcollected = postscollected[this.data.CurrentpostId];
postcollected = !postcollected;
postscollected[this.data.CurrentpostId] = postcollected;
},
(第一张图的收藏报这个错)
(第三张图的收藏报这个错)
2回答
-
Madao大仁
提问者
2018-03-21
= =奇怪了 把postcollect 和postscollect全部改成postCollect 和postsCollect, key值同理修改,就没问题了...
012018-03-21 -
Madao大仁
提问者
2018-03-21
oncollectionTap: function (event) {
var postscollected = wx.getStorageSync('post_collecting');
var postcollected = postscollected[this.data.CurrentpostId];
postcollected = !postcollected;
postscollected[this.data.CurrentpostId] = postcollected;
wx.setStorageSync('post_collecting', postscollected);
this.setData({
collected: postcollected
});
00
相似问题