vuex-crossviews-shared

1.1.6 • Public • Published

vuex-crossviews-shared

vuex跨窗口共享插件

支持移动端多webview页面vuex共享

NPM version NPM downloads

依赖

安装

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).如:
    filter = (mutation) => {
      if (mutation.type === 'example') {
         return true;
      }
    };
    
    唯一参数是mutation对象
  • 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,
    });

Readme

Keywords

none

Package Sidebar

Install

npm i vuex-crossviews-shared

Weekly Downloads

2

Version

1.1.6

License

ISC

Unpacked Size

43.8 kB

Total Files

12

Last publish

Collaborators

  • bunko