A plugin wrapped from localForage for Vue.js.
# install it via npm
npm install v-localforage --save
# install it via yarn
yarn add v-localforage
<!-- insert the vue core before it -->
<script src="https://unpkg.com/v-localforage"></script>
// register the plugin on vue
import VueLocalforage from 'v-localforage'
Vue.use(VueLocalforage)
// you can also pass options, check options reference below
Vue.use(VueLocalforage, Options)
let item = await this.$localforage.getItem(key)
await this.$localforage.setItem(key, value)
await this.$localforage.removeItem(key)
await this.$localforage.clear()
let length = await this.$localforage.length()
let k = await this.$localforage.key(keyIndex)
let keys = await this.$localforage.keys()
More informations on LocalForage documentation
You can register multiple instances, see below:
Vue.use(VueLocalforage, {
instances: [
{
storeName: 'instance1'
},
{
storeName: 'instance2'
}
]
})
// for instance1
await this.$localforage.instance1.setItem(key, value)
// for instance2
await this.$localforage.instance2.setItem(key, value)
- Default:
[]
You can create multiple instances.
- Default:
[localforage.INDEXEDDB, localforage.WEBSQL, localforage.LOCALSTORAGE]
The preferred driver(s) to use.
- Default:
localforage
The name of the database.
- Default:
4980736
The size of the database in bytes.
- Default:
keyvaluepairs
The name of the datastore.
- Default:
1.0
The schema version of your database.
- Default:
''
A description of the database.