반응형
Vue mapActions 구성 방법
vue-cli 스토어
mapActions ('일부/네스트/모듈', 'getCountry', 'getCurrency'),
Vue 구성 요소에서 mapActions 경로를 설정하는 방법
mapActions
컴포넌트의methods
소유물.
// my-component.vue
import { mapActions } from 'vuex'
export default {
...
methods: {
...mapActions('namespaced/module', [
'myAction',
'myOtherAction'
])
}
}
네임스페이스는 모듈의 파일명으로 판별할 수 있습니다.예를 들어, 파일이 지정되면 -moduleA.js
- getters, modiate, actions는 다음과 같이 명명됩니다.moduleA/someGetter
,moduleA/someAction
,moduleA/someMutation
.
...mapActions('moduleA', [
'someAction',
'anotherAction'
])
모듈이 등록되면 모듈이 등록된 경로에 따라 모든 게터, 동작 및 돌연변이가 자동으로 이름 지정됩니다.
또 다른 방법은,registerModule
method: 동적 런타임 등록을 허용합니다.
// register a module `myModule`
store.registerModule('myModule', {
// ...
})
// register a nested module `nested/myModule`
store.registerModule(['nested', 'myModule'], {
// ...
})
언급URL : https://stackoverflow.com/questions/49548718/how-to-configure-vue-mapactions
반응형
'programing' 카테고리의 다른 글
인수 반환이 정의되지 않은 Vuex getters를 테스트하는 것은 함수가 아닙니다. (0) | 2022.08.09 |
---|---|
Bool은 토종 C형인가요? (0) | 2022.08.09 |
Enum을 사용한 싱글턴 구현(Java) (0) | 2022.08.09 |
Vue js에서 확인란이 선택되어 있는지 확인하는 방법 (0) | 2022.08.09 |
플러그인을 사용해도 babel이 확산 연산자를 전치하도록 가져올 수 없습니다. (0) | 2022.08.09 |