vuex-crossviews-shared
vuex跨窗口共享插件
支持移动端多webview页面vuex共享
依赖
安装
npm install --save vuex-crossviews-shared
使用
const store = // ... plugins:
API
sharedVuex([options])
key <String>
: storage存储的key. (default: h5_vuex)paths <Array>
: 需要持久化存储的state数据.例:['a.b.c', 'a.b.d']
(default: [])filter <Function>
: 对触发storage更新的commit筛选方法(default:()=>true
).如:
唯一参数是mutation对象filter = (mutation) => { if (mutation.type === 'example') { return true; } };
event <Object>
: 自定以事件方法,用来做发布和响应自定义事件. (default: localstorage的原生监听事件,可能在ios上的UIWebView中失效) 它应包含三个方法://发布事件event;//取消事件event;//注册事件event;