小程序已经获取了缓存,getStorageSync获取数据时怎么还会发起网络请求?
//设置缓存 getlistdata(){ var that = this; wx.request({ url: 'https://api-hmugo-web.itheima.net/api/public/v1/categories', success(res) { that.List = res.data.message[0].children[0].children that.setData({ listdata: that.List }) wx.setStorageSync("listdata", { data: that.List }) } //加载缓存 onLoad: function (options) { const Listdata = wx.getStorageSync("listdata"); if (!Listdata){ this.getlistdata(); } else { this.setData({ listdata: Listdata.data }) } [图片] [图片] 两次编译都会发起请求,但是第二次的数据量比较少,刚学小程序,麻烦大神们指点指点