微信小程序 每次请求数据都把元素放入缓存数组中
// 假设这是从接口获取的数据 const newData = { id: 1, value: 'example' }; // 获取缓存数组,如果不存在则设置为空数组 const storageKey = 'dataArray'; let dataArray = wx.getStorageSync(storageKey) || []; // 将新数据添加到缓存数组中 dataArray.push(newData); // 保存更新后的缓存数组 wx.setStorageSync(storageKey, dataArray);