Following the video, an error was reported: Cannot create property '0' on string '';
尾生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