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

Package detail

vue-h-ls

haohao.love34MIT1.0.1

Vue plugin for work with LocalStorage from Vue context

storage, localstorage, local-storage, vue-localstorage, vuejs-localstorage, vue-local-storage, vuejs-local-storage, memorystroage, sessionstorage, session-storage, vue-sessionstorage, vuejs-sessionstorage, vue-session-storage, vuejs-session-storage, memory-stroage, vue-ls, vue, vuejs, vue-plugin, watch, es6-modules

readme

h-ls 本地永久存储,可设置过期时间

  1. 前端js使用localStorage的时候只能存字符串,不能存储对象

    h-ls 可以存储 object undefined number string

  2. localStorage没有过期时间

    h-ls 可以设置以天为单位的过期时间

安装

yarn add h-ls || npm i h-ls

使用

import LS from 'h-ls'

Vue.use(LS, { name: 'ls' })

let value = {name: 'xiejun'} // 设值 // set (key, value, expiredTime) // expiredTime 过期时间单位是天 1/8 === 3小时 this.$ls.set('key', value, 1)

// 获取值 this.$ls.get('key')

// 清楚所有缓存 this.$ls.clear()

// 删除某个key this.$ls.remove(key)