[vue3] vue3에서 vuex4 + module + ts 적용

Edward Hyun·2021년 12월 8일
0

app&web-dev

목록 보기
33/178

머리 아프다.
vue3에서는 vuex4를 쓰고 여기에 typescript를 적용한다.
또한 모듈화를 진행하면 점점 머리가 아파진다.

모듈에 대해서도 type을 설정해 줘야 하는데 type을 지정할 때 아래와 같다면,

const example : Module<exampleState, RootState> = {
  namespaced: true,
  state:
    {
      title: 'test',
      subtitle: ['test1','test2']
    },
};

Module< state타입, rootState > 로 모듈에 대한 타입정의를 해줘야 한다.
(배보다 배꼽이 더 큰 느낌이 드는 것은 나만의 착각일까?)

참고 :: https://kyounghwan01.github.io/blog/Vue/vue3/vuex-ts/#store-modulea-ts
https://kyounghwan01.github.io/blog/Vue/vue3/vuex-ts/#프로젝트-구조

profile
앱&웹개발(flutter, vuejs, typescript, react), 인공지능(nlp, asr, rl), 백엔드(nodejs, flask, golang, grpc, webrtc, aws, msa, nft, spring cloud, nest.js), 함수형 프로그래밍(scala, erlang)을 공부하며 정리합니다.

0개의 댓글