web前端全系列 教程
1839个小节阅读:2243.2k
目录
鸿蒙应用开发
C语言快速入门
JAVA全系列 教程
面向对象的程序设计语言
Python全系列 教程
Python3.x版本,未来主流的版本
人工智能 教程
顺势而为,AI创新未来
大厂算法 教程
算法,程序员自我提升必经之路
C++ 教程
一门通用计算机编程语言
微服务 教程
目前业界流行的框架组合
web前端全系列 教程
通向WEB技术世界的钥匙
大数据全系列 教程
站在云端操控万千数据
AIGC全能工具班
A A
White Night
本地存储也是实际项目中必备的接口,一些用户信息、数据信息等需要存储到本地
将 data 存储在本地缓存中指定的 key 中,会覆盖掉原来该 key 对应的内容,这是一个同步接口
xxxxxxxxxx
try {
uni.setStorageSync('storage_key', 'hello');
} catch (e) {
// error
}
从本地缓存中同步获取指定 key 对应的内容
xxxxxxxxxx
try {
const value = uni.getStorageSync('storage_key');
if (value) {
console.log(value);
}
} catch (e) {
// error
}
同步获取当前 storage 的相关信息
xxxxxxxxxx
try {
const res = uni.getStorageInfoSync();
console.log(res.keys);
console.log(res.currentSize);
console.log(res.limitSize);
} catch (e) {
// error
}
从本地缓存中同步移除指定 key
xxxxxxxxxx
try {
uni.removeStorageSync('storage_key');
} catch (e) {
// error
}
同步清理本地数据缓存
xxxxxxxxxx
try {
uni.clearStorageSync();
} catch (e) {
// error
}
实时效果反馈
1. uni-app中,本地存储中,删除指定存储信息的方法是:
A setStorageSync
B getStorageSync
C removeStorageSync
D clearStorageSync
答案
1=>C