5 . Index.ts로 관리

String_0·2023년 8월 8일
0

stores/index.ts
stores/counter.ts
stores/user.ts
stores/loader.ts
....

가 있다고 가정하자

이때, index.ts에서 나머지들을 관리할 수 있다.

stores/index.ts

import { useUserStore } from "@/stores/user";
import { useLoaderStore } from "@/stores/loader";
import { useSnbStore } from "@/stores/counter";
....

export const stores = {
  useUserStore,
  useSnbStore,
  useLoaderStore....
};


이것이 Vue에서 참조되는 것은 이렇게 쓰인다.

test.vue

import { stores } from "@/stores";
const snbStore = stores.useSnbStore();
profile
원인을 파악하자

0개의 댓글