Open riefuchi220 opened 5 months ago
// store/index.js import Vue from 'vue'; import Vuex from 'vuex'; Vue.use(Vuex); export default new Vuex.Store({ state: { imageUrls: [], videoStatus: 'not_started' // 初期ステータス }, getters: { getImageUrls: state => state.imageUrls, getVideoStatus: state => state.videoStatus }, mutations: { setImageUrls: (state, urls) => { state.imageUrls = urls; }, setVideoStatus: (state, status) => { state.videoStatus = status; } }, actions: { fetchImageUrls({ commit }) { // サーバーから画像URLを取得する処理をここに入れる // 結果をコミットしてstateに保存 fetch('https://example.com/api/images') .then(response => response.json()) .then(data => { commit('setImageUrls', data.imageUrls); }) .catch(error => { console.error('Error fetching image URLs:', error); }); } } });