Vuex VS Pinia
Vuex와 비교해보고 어떤 장점이 있는지 알아보자.
Vuex와의 차이점
Vuex란?
모듈 vs 다중 스토어(store)
프로젝트 내부에서 Vuex의 폴더 구조
src/
|-- store/
|-- index.js # Main store file where you combine modules
|-- state.js # Root state (optional, can be in index.js)
|-- mutations.js # Root mutations (optional, can be in index.js)
|-- actions.js # Root actions (optional, can be in index.js)
|-- getters.js # Root getters (optional, can be in index.js)
|-- modules/
|-- user.js # User module (state, mutations, actions, getters)
|-- cart.js # Cart module (state, mutations, actions, getters)
|-- products.js # Products module (state, mutations, actions, getters)
# ... other modules프로젝트 내부에서 Pinia의 폴더 구조
Vue2에서의 Vuex 사용방식
모듈 위치 파악이 어렵다.
namespace 사용 예시
Vue3에서 Pinia 사용
Last updated