LocalStorage plugin inspired by Vue typed props which take a care of typecasting for Vue.js 1 and 2 with SSR support.
Installnpm install vue-localstorage --save
or
Usagebower install vue-localstorage
Licenseimport VueLocalStorage from 'vue-localstorage'
Â
Vue.use(VueLocalStorage)
Vue.use(VueLocalStorage, {
  name: 'ls',
  bind: trueÂ
})
Â
Vue.localStorage.set('someNumber', 123)
Vue.localStorage.get('someNumber')
Â
Vue.localStorage.get('propertyThatNotExists', 'fallbackValue')Â
Â
Vue.localStorage.get('property', null, Number)
Â
var vm = new Vue({
  localStorage: {
    someObject: {
      type: Object,
      default: {
        hello: 'world'
      }
    },
    someNumber: {
      type: Number,
    },
    someBoolean: {
      type: Boolean
    },
    stringOne: '',
    stringTwo: {
      type: String,
      default: 'helloworld!'
    },
    stringThree: {
      default: 'hello'
    }
  },
  methods: {
    someMethod () {
      let lsValue = this.$localStorage.get('someObject')
      this.$localStorage.set('someBoolean', true)
      this.$localStorage.remove('stringOne')
    }
  }
})
[MIT]
RetroSearch is an open source project built by @garambo | Open a GitHub Issue
Search and Browse the WWW like it's 1997 | Search results from DuckDuckGo
HTML:
3.2
| Encoding:
UTF-8
| Version:
0.7.4