Vue js
LocalStorage vuex-persistedstate
갈잃자
2022. 5. 15. 19:56
vuex-persistedstate는 사용자 LocalStorage에 저장하여 만약 어떠한 데이터 변화를주고 새로고침을 하더라도 사용자 브라우저의 localstorage에 자동으로 저장해주는 라이브러리 중 하나이다.
사용방법
1. 설치
$ npm i vuex-persistedstate
2. 코드작성
//store.index.js
import createPersistedState from 'vuex-persistedstate'
Vue.use(Vuex)
export default new Vuex.Store({
plugins: [
createPersistedState(),
],
3. 저장된 데이터 확인!(개발자도구-Application-Local Storage)