search

Home  >  Q&A  >  body text

I got an error when I clicked on favorites.

Following the video, an error was reported: Cannot create property '0' on string '';



叶子叶子2183 days ago1349

reply all(2)I'll reply

  • 尾生

    尾生2019-04-27 16:15:50

    //When entering for the first time, determine whether there is local storage and whether to collect it

    var newsCollect = wx.getStorageSync('newsCollect');

    Represents previous collection or cancellation of collection

    If(newsCollect){

    var newCollect = newsCollect[options.newsid];

    this.setData({

                  collected:newCollect

    ##                                                                                                                                                                    NewsCollect[options. newsid] = false; :function(event){

    //NewCollect is the collection of all data

    var newsCollect = wx.getStorageSync('newsCollect');

    //newCollect is the current piece of data

    var newCollect=newsCollect[this.data.newsid];

    //When clicked, cancel if collected, collect if not collected

    newCollect= !newCollect ;

    //Update to local storage

    newsCollect[this.data.newsid] = newCollect;

    wx.setStorageSync('newsCollect' , newsCollect);

    This.setData({

                                                                                                                                                                                        use })

    console.log(newCollect);

    }

    This can come out

    reply
    0
  • 唐俊

    I'm in the same situation. If you write it like this, you'll still get an error.

    唐俊 · 2019-05-26 14:15:37
  • Cancelreply