터미널에 다음과 같은 명령을 실행
$npm install vuex@next
src/ 폴더 안에 store.js 파일 생성후 다음과 같은 스켈레톤 코드 작성
//Store.js
import { createStore } from 'vuex'
const store = createStore({
state(){
return {
}
},
})
export default store
main.js에서 store를 import후 다음과 같은 코드 작성
//main.js
...
import store from './store.js'
...
app.use(store),mount('#app')
'WEB > Vue' 카테고리의 다른 글
[Vue3] Vue3에서 vuex4 store 모듈화(2) state,mutation (0) | 2023.02.02 |
---|---|
[Vue3] Vue3에서 vuex4 store 모듈화(1) (0) | 2023.02.02 |
[Vue3] Vue-router 설치하기 (0) | 2023.01.15 |
[Vue2] Emit,Props를 통한 컴포넌트간 데이터 전달하기 (0) | 2022.12.29 |
[Vue2/Vuex] state 활용 맛보기 (0) | 2022.12.29 |