반응형
rest API를 사용하여 앱 부팅 시 Vuex 스토어를 올바르게 초기화하려면 어떻게 해야 합니까?
API에서 가져온 데이터를 사용하여 스토어를 초기화합니다(액시스를 사용하고 있습니다).앱 부팅 시 한 번만 어떻게 해야 하나요?
스토어를 내보내는 store.js 파일과 다음 작업을 수행하는 main.js 파일이 있습니다.
import Vue from "nativescript-vue";
import store from "./store";
new Vue({
store,
render: (h) => h("frame", [h(App)]),
}).$start();
도 한번 써보세요..dispatch()
Axios REST 하여 Axios REST API를 합니다.created()
Vue(Vue) :
new Vue({
store,
render: (h) => h("frame", [h(App)]),
created() {
this.$store.dispatch('myAxiosFetchFunction');
},
}).$start();
언급URL : https://stackoverflow.com/questions/57249465/how-to-properly-initialize-vuex-store-on-app-startup-using-rest-api
반응형
'programing' 카테고리의 다른 글
Vuejs 2에서 vuetable-2를 사용하여 데이터를 검색할 수 없습니다. (0) | 2022.08.13 |
---|---|
jest 및 avoriaz를 사용할 때 Vuejs의 컴포넌트에서 비동기 메서드를 테스트하는 방법 (0) | 2022.08.13 |
Vuejs가 입력의 포커스를 잃을 때까지 모델을 업데이트하지 않는 이유 (0) | 2022.08.12 |
Windows에서 Clang을 컴파일하는 방법 (0) | 2022.08.12 |
java.lang의 차이.RuntimeException 및 java.lang.예외. (0) | 2022.08.12 |