You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
LocalStorage plugin inspired by Vue typed props which take a care of typecasting for Vue.js 1 and 2 with SSR support.
Install
npm install vue-localstorage --save
or
bower install vue-localstorage
Usage
importVueLocalStoragefrom'vue-localstorage'Vue.use(VueLocalStorage)// Or you can specify any other name and use it via this.$ls, this.$whatEverYouWantVue.use(VueLocalStorage,{name: 'ls',bind: true//created computed members from your variable declarations})// Use localStorage from Vue objectVue.localStorage.set('someNumber',123)Vue.localStorage.get('someNumber')// Fallback value if nothing found in localStorageVue.localStorage.get('propertyThatNotExists','fallbackValue')// Will return 'fallbackValue' string// Default type if value isn't registered in localStorage sectionVue.localStorage.get('property',null,Number)//register localStorage variables and adds computed variables to local components//to be used like regular computeds that are stored in the localstoragevarvm=newVue({localStorage: {someObject: {type: Object,default: {hello: 'world'}},someNumber: {type: Number,},someBoolean: {type: Boolean},stringOne: '',stringTwo: {type: String,default: 'helloworld!'},stringThree: {default: 'hello'}},methods: {someMethod(){letlsValue=this.$localStorage.get('someObject')this.$localStorage.set('someBoolean',true)this.$localStorage.remove('stringOne')}}})