getChangeScroll(dataId) {
//重要!!! 如果缓存有,直接赋值,没有则
if(uni.getStorageSync('num'+dataId)){
this.currentList = uni.getStorageSync('num'+dataId)
}else{
//页面渲染
this.request({
url: this.http + this.urlList[3].paht,
data: {
id: dataId
}
})
.then(data => {
console.log(data);
if (this.currentList.length === 0) {
this.currentList = data.data;
} else {
this.currentList = null;
uni.setStorageSync("num"+dataId ,data.data)
this.currentList = data.data;
console.log(this.currentList)
}
})
}
},
2021/6/5 补充一点
避免缓存后无法获取到数据库更新,页面关闭时要清除此页面缓存
//
onUnload(){
//删除缓存
}