Vue plugin for work with LocalStorage from Vue context
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)