반응형
vuex 사용예시
-
[vue] vuex binding helper - vue store 사용하기프론트엔드/Vuejs 2021. 6. 25. 15:23
vue 에서 vuex 를 사용하여 store 를 만들면, getters 의 경우 this.$store.getters.[getter이름] 로 사용가능 actions 의 경우 this.$store.dispatch(‘[action이름]’, data) 과 같이 사용할 수 있다. 또는 직접 state 에 바로 접근해서 this.$store.state.book.message 로도 사용가능은 하다. helper 없이 기본적으로 사용 {{getMsg}} Click store/index.js store 를 하나만으로는 사용하기 어려우므로 기능별 또는 페이지별로 분리해야한다. 기능/페이지별로 store를 분리하고, 하나의 store에는 state, mutations, actions, getters를 포함해서 관리하는게 편..