鍍金池/ 問答/HTML/ vuex store.dispatch返回值怎么取

vuex store.dispatch返回值怎么取

我在全局的action里定義了一個方法,用于請求數(shù)據(jù)
saveForm (context,pay) {

Util.ajax({
    method: 'post',
    url: '/rest',
    data: pay
})

}

在組件中,我使用this.$store.dispatch('saveForm',JSON.stringify(pay)),把值傳過去,那么請求返回回來的值,我該怎么寫才能在組件里取到呢?

回答
編輯回答
影魅

首先你為什么放到dispatch 里, 如果你非要放到哪里 你可以 return Promise.resolve(你ajax的返回值)
.then(...)

2018年7月7日 19:01