1.1.4 • Published 6 years ago

vue-component-persist v1.1.4

Weekly downloads
2
License
MIT
Repository
github
Last release
6 years ago

vue-component-persist

Persist data in localStorage or anywhere for Vue.js apps

Install

yarn add vue-component-persist

Usage

import Persist from 'vue-component-persist'

Vue.use(Persist)

new Vue({
  template: '<input v-model="text" v-if="shown" />',

  data: {
    text: '',
    shown: false
  },

  persist: {
    text: 'persist-key:text',
    shown: {
      key: 'persist-key:shown',
      expiration: 1000 * 60
    }
  }
})

Then the data of text and shown will be stored at localStorage and kept in sync.

API

Vue.use(Persist, options)

options

read

Type: function Default: k => localStorage.getItem(k)

The function we use to get stored data.

write

Type: function Default: (k, v) => localStorage.setItem(k, v)

The function we use to store data.

clear

Type: function Default: k => localStorage.removeItem(k)

The function we use to clear data in store.

Original author

vue-persist © egoist, Released under the MIT License. Authored and maintained by egoist with help from contributors (list).

egoistian.com · GitHub @egoist · Twitter @rem_rin_rin

1.1.4

6 years ago

1.1.3

6 years ago

1.1.2

6 years ago

1.1.1

6 years ago

1.1.0

6 years ago

1.0.1

6 years ago

1.0.0

6 years ago