// 本地数据存储 var arr_user = new Array(); var user0 = new Object(); user0.id = 1; user0.title = "乾"; arr_user[0] = user0; var user1 = new Object(); user1.id = 2; user1.title = "坤"; arr_user[1] = user1; // 异步缓存数据 wx.setStorage({ key: 'bagua0', data: arr_user, }); // 同步缓存数据 wx.setStorageSync('bagua1', arr_user); // 异步获取本地缓存数据 wx.getStorage({ key: 'bagua0', success: function(res) { console.log('getStorage:' + JSON.stringify(res.data)); }, }); // 同步获取本地缓存数据 var bagua1 = wx.getStorageSync('bagua1'); console.log('getStorageSync:' + JSON.stringify(bagua1));