모듈
-
Vuex 핵심 컨셉(5) - 모듈(module)Vue/Vuex 2021. 7. 2. 11:35
단일 상태 트리를 사용하기 때문에 어플리케이션의 하나의 큰 객체 안에 포함 규모가 커짐에 따라 저장소는 매우 비대해질 수 있다. 이를 위해 Vuex는 Store를 모듈로 나눌 수 있다. 각 모듈은 자체 상태, 변이, 액션, getters 및 중첩된 모듈을 포함할 수 있다. const moduleA = { state: () => ({ ... }), mutations: { ... }, actions: { ... }, getters: { ... } } const moduleB = { state: () => ({ ... }), mutations: { ... }, actions: { ... } } const store = createStore({ modules: { a: moduleA, b: moduleB } }..