uni-app的本地储存 类似h5的localstorage
在安卓端上是不支持localstorage的,uni-app的本地储存是什么?
1、将数据存储在本地缓存中指定的 key 中,会覆盖掉原来该 key 对应的内容,这是一个异步接口。
uni.setStorage({key: 'storage_key',data: 'hello'});
2、从本地缓存中异步获取指定 key 对应的内容。
uni.getStorage({
key: 'storage_key',
success: function (res) {
console.log(res.data);
let Storage_data = res.data;
}
});
3、从本地缓存中异步移除指定 key。
uni.removeStorage({key: 'storage_key'});
4、清理本地所有数据缓存。
uni.clearStorage();