如下,如何获取children然后更新到father.children中,页面就可以列表展示了state: { father: [ { name: 'wang', children: [] } ]}action: { getChildren(fatherId).then(children => { // 获得children,如何更新到father.children中 });}
1 回答
交互式爱情
TA贡献1712条经验 获得超3个赞
state: {
father: [
{
name: 'wang',
children: []
}
]
},
mutations:{
updateChildren(state,children){
state.father[0].children = children;
}
},
actions: {
updateChildren({commit}){
getChildren(fatherId).then(children => {
// 获得children,如何更新到father.children中
commit("updateChildren",children );
});
}
}
大概这样吧,去看看文档吧
添加回答
举报
0/150
提交
取消