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;

},

http://img.mukewang.com/szimg/5ab1f9720001b1e608530187.jpg(第一张图的收藏报这个错)



http://img.mukewang.com/szimg/5ab1f9970001986108590055.jpg(第三张图的收藏报这个错)

写回答

2回答

Madao大仁

提问者

2018-03-21

= =奇怪了  把postcollect 和postscollect全部改成postCollect 和postsCollect, key值同理修改,就没问题了...   

0
1
7七月
我课程里是怎么定义的,我不会定义全小写吧?
2018-03-21
共1条回复

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

    });


0
0

微信小程序入门与实战(全新版) 超20000人学习的好课

4年同步微信官方迭代,累计20000+人学习, 比微信官方更火爆!

23866 学习 · 6899 问题

查看课程