异步存缓存
uni.setStorage({
key: "键名",
data: "值",
success:()=>{
console.log("存储成功");
},
})
异步取缓存
uni.getStorage({
key:"键名",
success:(res)=>{
console.log(res);
}
})
异步清除指定缓存
uni.removeStorage({
key:"键名",
success:()=>{
console.log("清除成功");
}
})
个人建议使用同步方法
同步存缓存
uni.setStorageSync("键名","值");
同步取缓存
uni.getStorageSync("键名")
同步清除指定缓存
uni.removeStorageSync("键名")
清除本地所有缓存(不建议使用)
uni.clearStorageSync()