<script src="localforage.js"></script>。你不需要运行任何初始化方法或等待 onready 事件。
localStorage-like API. It allows developers to store many types of data instead of just strings.
<script src="localforage.js"></script>. You don't need to run any init method or wait for any
setItem(key, value, successCallback)
iteratorCallbackis called once for each pair, with the following arguments:
iteratesupports early exit by returning non `undefined` value inside `iteratorCallback` callback. Resulting value will be passed to `successCallback` as the result of iteration. This means if you're using CoffeeScript, you'll need to manually `return` nothing to keep iterating through each key/value pair.
setDriver()with one or more of the following arguments:
setDriver(). The following config values can be set:
setDriver, above. Default:
[localforage.INDEXEDDB, localforage.WEBSQL, localforage.LOCALSTORAGE]name The name of the database. May appear during storage limit prompts. Useful to use the name of your app here. In localStorage, this is used as a key prefix for all keys stored in localStorage. Default:
'localforage'size The size of the database in bytes. Used only in WebSQL for now. Default:
4980736storeName The name of the datastore. In IndexedDB this is the
dataStore, in WebSQL this is the name of the key/value table in the database. Must be alphanumeric, with underscores. Any non-alphanumeric characters will be converted to underscores. Default:
'keyvaluepairs'version The schema version of your database. Used only in WebSQL and IndexedDB. In WebSQL, this simply sets the version, and in IndexedDB this may trigger an
onupgradeneededevent if a version upgrade is detected. If a new store is detected, localForage will ask IndexedDB to increment the version itself to manually trigger the
onupgradeneededevent. As of right now, upgrade events are not customizable, but may be in the future. For drivers that do not support configuration for versioning, this value simply gets thrown away. Default:
1.0description A description of the database, essentially for developer usage. Default:
configmethod is synchronous.
callbackargument and that you pass the same arguments to callbacks as the default drivers do. You'll also want to resolve or reject promises. Check any of the default drivers for an idea of how to implement your own, custom driver.
_supportproperty that is either boolean (
false) or returns a
Promisethat resolves to a boolean value. If
_supportis omitted, then
trueis the default value. You can use this to make sure the browser in use supports your custom driver.
nullduring the asynchronous driver initialization process (see
readyfor more details), or
nullif the asynchronous driver initialization process failed to find a usable driver.
ready()provides a way to determine whether the asynchronous driver initialization process has finished. That's useful in cases like when we want to know which driver localForage has settled down using.
driverNameis supported by the browser.
storeNameproperties, it drops the specified "store". When invoked with an object specifying only a
nameproperty, it drops the specified "database" (and all its stores).