Important: This documentation covers Yarn 1 (Classic).
For Yarn 2+ docs and migration guide, see yarnpkg.com.

Package detail

@deepjs/uni-storage

cloudyan457MIT0.3.8

封装 uni-app 的 storage,同步取,异步存,API 简单

storage, uni-app, deepjs

readme

uni-storage

封装 uni-app 的 storage,同步取,异步存,API 简单

独立包,无依赖,语义化,使用简单

功能列表

  • set(key, value, time = 3600) // time 单位秒,默认 1h
  • get(key) // 无则返回 undefined
  • remove(key) // 删除
  • clear(bool) // 清除 storage,传 true 则清除所有类型的缓存

使用

import storage from '@deepjs/uni-storage'

// 也可以直接挂载到 Vue 上
Vue.use(storage)

storage.set('name', 'cloudyan', 5);
storage.get('name');

setTimeout(() => {
  storage.get('name');
  storage.remove('name');
  storage.clear('name');
}, 6000);