rc-cookie
v1.0.10
Published
一个便捷使用cookie的工具库
Downloads
490
Readme
cookie 🔧
介绍
提供一些 cookie 操作方法,如:设置、获取、删除、清空等。
安装
npm install --save rc-cookie
使用
- 获取 cookie
import { parseCookie } from "rc-cookie";
// 获取单个 cookie
const cookie = parseCookie("token");
// 获取 所有cookie 对象
const cookies = parseCookie();
- 使用工具类
import { CookieStorage } from "rc-cookie";
// 设置 cookie
CookieStorage.setItem("token", "123456");
// 获取 单个 cookie
CookieStorage.getItem("token");
// 删除 单个 cookie
CookieStorage.removeItem("token");
// 清空 cookie
CookieStorage.clear();