Vue | Vue-ls插件
3 月,跳不动了?>>> Vue插件,用于从Vue上下文中使用本地Storage,会话Storage和内存Storage 一个vue封装的本地储存的方法。 安装 Npm npm install vue-ls --save Yarn yarn add vue-ls 使用 Vue-ls Storage API import Storage from 'vue-ls' ; options = { namespace : 'vuejs__' , // key键前缀 name : 'ls' , // 命名Vue变量.[ls]或this.[$ls], storage : 'local' , // 存储名称: session, local, memory } ; Vue . use ( Storage , options ) ; // 或 Vue.use(Storage); new Vue ( { el : '#app' , mounted : function ( ) { Vue . ls . set ( 'foo' , 'boo' ) ; // 设置有效期 Vue . ls . set ( 'foo' , 'boo' , 60 * 60 * 1000 ) ; //有效1小时 Vue . ls . get ( 'foo' ) ; Vue . ls . get ( 'boo' , 10 ) ;