数据缓存
有同步接口和异步接口。推荐使用同步接口。(异步自己看 官网)
同步接口
//缓存数据 <button @click="save" type="warn">数据缓存</button> save(){ console.log('点击了该按钮'), uni.setStorageSync('id' , 100) } //读取缓存数据 <button @click="get" type="default">获取缓存数据</button> get(){ const data = uni.getStorageSync("id"); console.log(data) } //移除缓存数据 <button @click="remove" type="primary"> 移除缓存数据</button> remove(){ uni.removeStorageSync("id"), console.log("移除成功") } //还有个清除本地所有数据的。就不说了,更用不着。