query.find().then((results) => {
var resultsthat = results[0];
resultsthat[‘classaid’] = that.data.years[that.data.indexY];//修改了classaid
wx.showModal({
title: ‘收藏’,
content: clbms,
success: function (res) {
if (res.confirm) {
clarr = wx.getStorageSync(‘favo’) || [];
clarr.push(resultsthat);
that.setData({
favos: clarr,
});
wx.setStorageSync(‘favo’, that.data.favos);
console.log(‘已收藏:’ + clarr[clarr.length - 1].classaid);//得到了修改后的值
clarr = wx.getStorageSync(‘favo’) || [];
console.log(‘已收藏2:’ + clarr[clarr.length - 1].classaid);//依然是修改前的值??????为什么?
console.log(‘已收藏3:’ + that.data.favos[that.data.favos.length - 1].classaid);//得到了修改后的值