Package Exports
- vue-ls
This package does not declare an exports field, so the exports above have been automatically detected and optimized by JSPM instead. If any package subpath is missing, it is recommended to post an issue to the original package (vue-ls) to support the "exports" field. If that is not possible, create a JSPM override to customize the exports field for this package.
Readme
vue-ls
Vue plugin for work with LocalStorage from Vue context
Install
npm install vue-ls --save
or
yarn install vue-ls
Development Setup
# install dependencies
npm install
# build dist files
npm run build
Usage
Vue localStorage API.
import VueLocalStorage from 'vue-ls';
Vue.use(new VueLocalStorage);
new Vue({
el: '#app',
mounted: function() {
this.$localStorage.set('foo', 'boo');
//Set expire for item
this.$localStorage.set('foo', 'boo', 60 * 60 * 1000); //expiry 1 hour
this.$localStorage.get('foo');
this.$localStorage.get('boo', 10); //if not set boo returned default 10
let callback = (val, oldVal, uri) => {
console.log('localStorage chnage', val);
}
this.$localStorage.on('foo', callback) //watch change foo key and triggered callback
this.$localStorage.off('foo', callback) //unwatch
this.$localStorage.remove('foo');
}
});