wxbox-storage
v1.0.1
Published
[🎁 微信小程序工具盒] 微信小程序缓存接口增强
Downloads
28
Readme
wxbox-storage
[🎁 微信小程序工具盒] 微信小程序缓存接口增强
安装
npm i wxbox-storage使用
import Storage from 'wxbox-storage'
// 提供配置信息(可选)
const storage = new Storage({
prefix: 'app',
expire: 0
})
// 设置缓存
storage.set('id', 1)
// 设置过期时间
storage.set('token', 'abcdefg', 7200)
// 获取缓存
storage.get('token')
// 移除某个缓存
storage.remove('token')
// 清除所有缓存
storage.clear()在小程序中使用npm包前,需先构建 npm
// 使用 typescript 模板的项目,需额外配置 `project.config.json` 文件
"packNpmManually": true,
"packNpmRelationList": [
{
"packageJsonPath": "./package.json",
"miniprogramNpmDistDir": "./miniprogram"
}
]