sourcecode

모듈과 함께 vuexfire를 사용할 때 돌연변이를 처리하는 방법은 무엇입니까?

copyscript 2022. 8. 13. 12:25
반응형

모듈과 함께 vuexfire를 사용할 때 돌연변이를 처리하는 방법은 무엇입니까?

다음은 vuexfire 설명서의 모듈과 함께 돌연변이를 사용하는 것과 관련하여 일부 코드 조각과 함께 기술되어 있습니다.

루트 스토어에 돌연변이를 추가하고 먼저 상태에서 바인딩할 속성을 정의하십시오.

import { vuexfireMutations } from 'vuexfire'
const store = new Vuex.Store({
  state: {
    todos: [], // Will be bound as an array
    user: null, // Will be bound as an object
  },
  mutations: {
    // your mutations
    ...vuexfireMutations,
  },
})

모듈에서도 작동하지만 다음과 같이 돌연변이를 추가해서는 안 됩니다.

const store = new Vuex.Store({
  modules: {
    todos: {
      state: {
        todos: [], // Will be bound as an array
        user: null, // Will be bound as an object
      },
    },
  },
})

문제는 대규모 프로젝트에서 돌연변이를 처리하는 올바른 방법이 무엇인가 하는 것입니다.모듈이 20~30개 정도 되는 프로젝트가 있는 경우 모든 모듈 돌연변이를 루트 객체에 넣어야 합니까?돌연변이를 위한 추가 파일을 생성해야 합니까?아니면 이 파일을 구조화하기 위한 올바른 방법은 무엇입니까?

언급URL : https://stackoverflow.com/questions/64175196/how-to-handle-mutations-when-using-vuexfire-with-modules

반응형