반응형
Vue setup() 메서드로 Vuex 스토어에 액세스하는 방법
Vue에 있는 Vuex 스토어에 액세스하려면setup()
방법?
나는 일반에 접속할 수 없다.this.$store
더 이상 변수입니다.
구성 API 설명서에 따르면 다음 구문을 사용해야 합니다.
import { useStore } from 'vuex'
export default {
setup () {
const store = useStore()
return {
// access a state in computed function
count: computed(() => store.state.count),
// access a getter in computed function
double: computed(() => store.getters.double)
}
}
}
언급URL : https://stackoverflow.com/questions/68837893/how-to-access-vuex-store-in-vue-setup-method
반응형
'programing' 카테고리의 다른 글
vue 2에서 구성 요소의 루트 요소에 대한 이벤트를 테스트하는 방법 (0) | 2022.07.02 |
---|---|
Java: 날짜에서 월 정수 가져오기 (0) | 2022.07.02 |
Electron-Vue 응용 프로그램의 상태는 어디에 저장됩니까? (0) | 2022.07.02 |
2바이트 어레이를 쉽게 연결하는 방법 (0) | 2022.07.02 |
VueCli 3을 사용하여 index.html의 app.js 파일 이름을 변경하는 방법 (0) | 2022.07.02 |