Skip to content

데이터 영속 관리를 위하여 session에 저장해야합니다. #34

Description

@kwangilcho

vue-session을 활용하여 component - vuex - localStorage 구조를 만들어서 데이터 영속 관리를 합시다.

예시:

In main.js

importVueSessionfrom'vue-session'Vue.use(VueSession,{persist: true})

In Store.js or store/index.js

importVuefrom'vue'importVuexfrom'vuex'Vue.use(Vuex)letstore=newVuex.Store({state: {isLoggedIn: false,},getters: {isLoggedIn:function(state){returnstate.isLoggedIn;},user:function(state){// console.log(store);returnstore._vm.$session.get('user');}},mutations: {saveUser(state,payload){console.log('user payload',payload);// this._vm.$session.start();store._vm.$session.set('user',payload);state.isLoggedIn=(payload!=null)}},actions: {}});exportdefaultstore

Metadata

Metadata

Labels

No labels
No labels

Type

No type

Projects

No projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions