https://developers.weixin.qq.com/miniprogram/dev/api/storage/wx.setStorageSync.html
Page({
data: {
cid: 1, // 用于描述当前选中的电影类别id
movies: [] // 用于描述当前电影列表
},
/** 点击顶部导航后执行 */
tapNav(event){
let id = event.target.dataset.id // 当前选中组件的data-id
this.setData({cid: id})
// 发请求加载选中类别下的首页数据,更新电影列表
this.loadData(id, 0).then(movies=>{
this.setData({movies})
// 将movies存入缓存
wx.setStorage({
key: id,
data: movies
})
})
},