【发布时间】:2019-12-27 02:55:09
【问题描述】:
我想对后续问题使用重新计算或其他方式。
当我保存从someData 呈现的项目时,更新的数据会发送到服务器。
我想刷新someData,以便我们可以从服务器看到更新的someData。
$recomputed('someData') 不工作。
我认为我应该使用Promise,但不知道如何以及在何处实现它。
如果有人在这个问题上帮助我,我将不胜感激。感谢您的帮助。
组件:
computed : someData : function() {
return this.getData()// this is getters in the store
}
mounted() {
this.pullData() //this is actions for fetching data in the store,
this action commits fetched data to the state for getters
计算属性someData 在模板中使用。
我要编辑并保存someData。
商店
const actions = {
async pullData(commit){
await ...// fetch data from apis and commit
}
}
const getters = {
getData : state.data
}
还实现了突变。
这不会渲染someData,我的意思是someData 在渲染后是空的
组件。
data : { someData : [] },
mounted (){
this.pullData();
this.someData = this.getData()
}
【问题讨论】:
标签: api vue.js vuex computed-properties