Skip to content
目录

localStorage 永久存储

示例

显示代码
typescript
import { localStorage } from "@big0range/utils";
// 设置永久缓存
localStorage.set("a", { a: 12 });
// 获取永久缓存
localStorage.get("a");
// 移除永久缓存
localStorage.remove();
// 移除全部永久缓存
localStorage.clear();

set (设置永久缓存)

localStorage.set(key,value)

参数说明类型可选值默认
keykeystring
valuevalueany

get (获取永久缓存)

localStorage.set(key) 返回值为存入的数据

参数说明类型可选值默认
keykeystring

remove (移除永久缓存)

localStorage.remove(key)

参数说明类型可选值默认
keykeystring

clear (移除全部永久缓存)

localStorage.clear()

参数说明类型可选值默认