# storage **Repository Path**: chinafaker/storage ## Basic Information - **Project Name**: storage - **Description**: 封装了支持设置有效期的storage js - **Primary Language**: Unknown - **License**: MulanPSL-2.0 - **Default Branch**: master - **Homepage**: None - **GVP Project**: No ## Statistics - **Stars**: 1 - **Forks**: 0 - **Created**: 2022-01-05 - **Last Updated**: 2022-01-05 ## Categories & Tags **Categories**: Uncategorized **Tags**: None ## README # storage #### 介绍 封装了支持设置有效期的storage js #### 软件架构 由TypeScript编写 #### 安装教程 1. git clone https://gitee.com/chinafaker/storage.git 2. 如果是js项目 就引入js 如果是 ts项目就引入ts 3. 开箱即用 #### 使用说明 1. 引入import Localstorage from "@/unit/storage/index"; 路径换成自己的 初始化 const ls = new Localstorage(true 项目名称); 2. set方法 设置值 参数是一个对象 需要 key:string value:any time:string | number 返回是一个promise ls.set({key:"aab",value:[{name:123}],time:1641366308000}).then(res=>{ console.log(res) }).catch(e=>{ console.log(e) }) 3. get方法 读取值 //需要一个key值 返回一个promise ls.get('aab').then(res=>{ console.log(res) }).catch(e=>{ console.log(e) }) 4. remove 删除单个 //需要一个key值返回一个promise ls.remove('bbb').then(res=>{console.log(res)}) 5. clear //无参数 直接调用即可 清空所有存储 ls.clear().then((res: any) => { console.log(res); }); #### 参与贡献 1. Fork 本仓库 2. 新建 Feat_xxx 分支 3. 提交代码 4. 新建 Pull Request