如下,如何獲取children然后更新到father.children中,頁面就可以列表展示了state: { father: [ { name: 'wang', children: [] } ]}action: { getChildren(fatherId).then(children => { // 獲得children,如何更新到father.children中 });}
1 回答

交互式愛情
TA貢獻(xiàn)1712條經(jīng)驗(yàn) 獲得超3個(gè)贊
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 );
});
}
}
大概這樣吧,去看看文檔吧
添加回答
舉報(bào)
0/150
提交
取消