VUE—storejs一款好用的本地存储插件

一、安装

npm install storejs --save

二、引入

import storeLocal from 'storejs';
Vue.prototype.$storeLocal = storeLocal;// 定义 localStorage 组件

三、使用

this.$storeLocal.set('local_test',{'name':www,'age':2});

四、API

 // 存储变量到user键
store.set('user', { name:'Marcus' })
//获取内容
store.get('user')
// 删除键
store.remove('user')
// 清除所有的键
store.clearAll()
// 循环显示所有的键值对
store.eachEach(function(key, value) {
    console.log(key, '==', value)
})

你可能感兴趣的:(VUE—storejs一款好用的本地存储插件)