文章詳情頁
javascript - 一個vuex的問題
瀏覽:120日期:2023-02-10 13:08:59
問題描述
如下,如何獲取children然后更新到father.children中,頁面就可以列表展示了
state: { father: [{ name: ’wang’, children: []} ]}action: { getChildren(fatherId).then(children => {// 獲得children,如何更新到father.children中 });}
問題解答
回答1: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 );}); }}
大概這樣吧,去看看文檔吧
標簽:
JavaScript
相關文章:
1. javascript - 微信網頁開發從菜單進入頁面后,按返回鍵沒有關閉瀏覽器而是刷新當前頁面,求解決?2. php傳對應的id值為什么傳不了啊有木有大神會的看我下方截圖3. extra沒有加載出來4. mysql replace 死鎖5. android - 安卓做前端,PHP做后臺服務器 有什么需要注意的?6. python3.x - Python not 運算符的問題7. python - 數據與循環次數對應不上8. mysql - ubuntu開啟3306端口失敗,有什么辦法可以解決?9. mysql - C#連接數據庫時一直這一句出問題int i = cmd.ExecuteNonQuery();10. 求救一下,用新版的phpstudy,數據庫過段時間會消失是什么情況?
排行榜
