1.1.6 • Published 6 years ago
vuex-crossviews-shared v1.1.6
vuex-crossviews-shared
vuex跨窗口共享插件
支持移动端多webview页面vuex共享
依赖
安装
npm install --save vuex-crossviews-shared使用
import sharedVuex from 'vuex-crossviews-shared'
const store = new Vuex.Store({
// ...
plugins: [sharedVuex()],
})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.emit({ type: key, data: state, }); //取消事件 event.off({ type: key, handler: window._vuexhandle, }); //注册事件 event.on({ type: key, handler: window._vuexhandle, });