对于后续问题,我想使用重新计算或其他方法。当我保存从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()
}发布于 2019-08-22 04:17:55
https://stackoverflow.com/questions/57598216
复制相似问题