1.0.1 • Published 4 years ago
store-storage v1.0.1
store-storag
- vuex持久化方案(与nuxt配合使用)
下载
- npm install store-storag
使用
// 使用nuxt提供的插件模式, 下面代码写在插件文件中
import {
get,
save
} from 'store-storage';
export default ({ store }) => {
window.onNuxtReady(() => {
const myPlugin = store => {
get(store);
store.subscribe((mutation, state) => {
if(mutation.type.indexOf('/') == -1) {
return;
}
save(mutation, state);
});
};
myPlugin(store);
});
};
// nuxt.config.js
{
plugins: [
{ src: '~/plugins/nuxt-store-storage', ssr: false }
]
}