企业🤖AI智能体构建引擎,智能编排和调试,一键部署,支持私有化部署方案 广告
[TOC] # 插件 store 本地存储 store为需要本地存储的解决方案 ## 使用示例 ```javascript var store = v.store // 存储username为vace store.set('username', 'vace') // 获取 'username' store.get('username') // 删除 'username' store.remove('username') // 清楚所有本地存储,非特殊情况不要使用,会删了队友的- - store.clear() // 可存储对象,内部使用JSON.stringify序列化 store.set('user', { name: 'marcus', likes: 'javascript' }) // 内部会尝试JSON.parse 解析字符串,不用自己解析 var user = store.get('user') alert(user.name + ' likes ' + user.likes) // 获取所有的本地存储 store.getAll().user.name == 'marcus' // 循环读取存储内容 store.forEach(function(key, val) { console.log(key, '==', val) }) ``` ## API使用 * `v.store.set(key,value)` * `v.store.get(key,defaultValue='')` * `v.store.has(key)` * `v.store.remove(key)` * `v.store.clear()` * `v.store.getAll()` * `v.store.forEach(cb)` ## 兼容概览 ------------------ - Tested in iOS 4+ - Tested in Firefox 3.5 - Tested in Firefox 3.6 - Tested in Firefox 4.0+ - Support dropped for Firefox < 3.5 (see notes below) - Tested in Chrome 5 - Tested in Chrome 6 - Tested in Chrome 7 - Tested in Chrome 8 - Tested in Chrome 10 - Tested in Chrome 11+ - Tested in Safari 4 - Tested in Safari 5 - Tested in IE6 - Tested in IE7 - Tested in IE8 - Tested in IE9 - Tested in IE10 - Tested in Opera 10 - Tested in Opera 11 - Tested in Opera 12