文章詳情頁
javascript - 一個vuex的問題
瀏覽:105日期: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 );}); }}
大概這樣吧,去看看文檔吧
標(biāo)簽:
JavaScript
上一條:javascript - sqlite存時間戳再取出來的值不對下一條:javascript - 多個按鈕點擊顯示不同內(nèi)容后,怎么讓其內(nèi)容顯示一次,其他的按鈕點擊的內(nèi)容隱藏呢
相關(guān)文章:
1. javascript - JS如何取對稱范圍的隨機(jī)數(shù)?2. java - ehcache緩存用的是虛擬機(jī)內(nèi)存么?3. 數(shù)據(jù)庫 - mysql如何處理數(shù)據(jù)變化中的事務(wù)?4. android - java 泛型不支持?jǐn)?shù)組,那么RxJava的Map集合有什么方便的手段可以定義獲得一串共同父類集合數(shù)據(jù)呢?5. java - mongodb分片集群下,count和聚合統(tǒng)計問題6. 關(guān)于docker下的nginx壓力測試7. 服務(wù)器端 - 采用nginx做web服務(wù)器,C++開發(fā)應(yīng)用程序 出現(xiàn)拒絕連接請求?8. javascript - 有什么兼容性比較好的辦法來判斷瀏覽器窗口的類型?9. dockerfile - 我用docker build的時候出現(xiàn)下邊問題 麻煩幫我看一下10. python - pandas按照列A和列B分組,將列C求平均數(shù),怎樣才能生成一個列A,B,C的dataframe
排行榜

熱門標(biāo)簽