"Vuex modules"의 두 판 사이의 차이

잔글 (봇: 자동으로 텍스트 교체 (-</source> +</syntaxhighlight>, -<source +<syntaxhighlight ))
 
(다른 사용자 한 명의 중간 판 하나는 보이지 않습니다)
7번째 줄: 7번째 줄:
* 각 모듈은 각자의 상태, 변이, 액션, 게터뿐만 아니라 중첩된(nested) 모듈도 가질 수 있다.
* 각 모듈은 각자의 상태, 변이, 액션, 게터뿐만 아니라 중첩된(nested) 모듈도 가질 수 있다.


<source lang='javascript'>
<syntaxhighlight lang='javascript'>
const moduleA = {
const moduleA = {
   state: () => ({ ... }),
   state: () => ({ ... }),
30번째 줄: 30번째 줄:
store.state.a // -> moduleA의 state
store.state.a // -> moduleA의 state
store.state.b // -> moduleB의 state
store.state.b // -> moduleB의 state
</source>
</syntaxhighlight>
 
==같이 보기==
* [[Vuex 애플리케이션 구조]]


==참고==
==참고==

2020년 11월 2일 (월) 02:54 기준 최신판

1 개요[ | ]

Vuex modules
Vuex 모듈
  • 단일 상태 트리를 사용하면, 애플리케이션의 모든 상태가 하나의 큰 객체 안에 담기게 된다.
  • 규모가 커지다보면 그 저장소가 너무 비대해질 수 있다.
  • 이러한 단점을 해소하기 위해 Vuex는 저장소를 모듈별로 나눌 수 있게 되어 있다.
  • 각 모듈은 각자의 상태, 변이, 액션, 게터뿐만 아니라 중첩된(nested) 모듈도 가질 수 있다.
const moduleA = {
  state: () => ({ ... }),
  mutations: { ... },
  actions: { ... },
  getters: { ... }
}

const moduleB = {
  state: () => ({ ... }),
  mutations: { ... },
  actions: { ... }
}

const store = new Vuex.Store({
  modules: {
    a: moduleA,
    b: moduleB
  }
})

store.state.a // -> moduleA의 state
store.state.b // -> moduleB의 state

2 같이 보기[ | ]

3 참고[ | ]

문서 댓글 ({{ doc_comments.length }})
{{ comment.name }} {{ comment.created | snstime }}