2017-12-04 36 views
0

私は現在Vueプロジェクトに取り組んでいます。私は状態管理にVuexを使用しています。しかし、私が下の2つのアクションを私のコンポーネントでmapactionsとmapgettersでバインドすると、最大コールスタックサイズが私のコンソールのエラーを超えました。VueJS/VueX最大呼び出しスタックサイズを超えました

私は何が間違っているのか分かりません。私のサービスで

Screenshot of error

import Vue from 'vue' 
import Vuex from 'vuex' 
import service from "../services/statisticsService" 
import moment from 'moment' 

Vue.use(Vuex) 

const state = { 
    customersAndServicesOverTime:[], 
    counters:{} 
} 
const actions = { 
    actGetAllData(context){ 
     context.dispatch('actGetCustomersAndServicesOverTime') 
     context.dispatch('actGetCounters') 
    }, 

    actGetCustomersAndServicesOverTime(context){ 
     service.getCustomerAndServicesOverTime(context.getters.getJWT) 
      .then(response =>{ 
       context.commit('mutCustomersAndServicesOverTime', response.body) 
      }) 
    }, 
    actGetCounters(context){ 
     service.getCounts(context.getters.getJWT) 
      .then(response =>{ 
       context.commit('mutCounts', response.body) 
      }) 
    } 
} 
const mutations = { 
    mutCustomersAndServicesOverTime(state,payload){ 
     state.customersAndServicesOverTime ={ 
      labels:payload.map(x => moment(x.created).format("DD-MM-YYYY")), 
      datasets:[{ 
       data:payload.map(x => x.customersCount), 
       backgroundColor:"rgba(52, 73, 94,0.5)", 
       label:"customers",lineTension:0 
      },{ 
       data:payload.map(x => x.servicesCount), 
       backgroundColor:"rgba(230, 126, 34,0.5)", 
       label:"services",lineTension:0 
      }]} 
    }, 
    mutCounts(state,payload){ 
     state.counters = payload 
    }, 
} 
const getters = { 
    getCustomersAndServicesOverTime:state=>state.customersAndServicesOverTime, 
    getCounts:state=>state.counters, 
} 

export default { 
    state, 
    getters, 
    actions, 
    mutations 
} 

私は私のAPIと接続する2つの関数を宣言しました。

import Vue from 'vue' 
import VueResource from 'vue-resource' 
import CONFIG from "../config" 

export default { 
    getCounts(jwt) { 
     return Vue.http.get(CONFIG.API + "statistics/counts", { 
      headers: { 
       'Content-Type': 'application/json' 
       ,'Authorization': 'Bearer ' + jwt 
      } 
     }) 
    }, 
    getCustomerAndServicesOverTime(jwt) { 
     return Vue.http.get(CONFIG.API + "statistics/customersandservicesovertime", { 
      headers: { 
       'Content-Type': 'application/json' 
       ,'Authorization': 'Bearer ' + jwt 
      } 
     }) 
    } 
} 
+0

あなたが自分自身の中から何かを呼び出している可能性が高いです。したがって、無限ループはそのメッセージを引き起こします。無限ループの参照コード – samayo

+0

これは私がどこでも読んだものです。しかしどこで見つけることができません...私はすでに私の店ですべてを書き直しました... – ivancoene

+1

赤のファイルをクリックして、多分それはエラーのソース行を表示します – samayo

答えて

1

vuexの問題ではありませんでした。私はvue-chartjsを使用しています。私はオブジェクトインスタンスをハードコピーしませんでしたが、参照として使用しました。これは、最大コールスタックサイズ超過エラーを引き起こします。

https://github.com/apertureless/vue-chartjs/issues/197

関連する問題