文章詳情頁
javascript - 一個(gè)vuex的問題
瀏覽:128日期: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存時(shí)間戳再取出來的值不對下一條:javascript - 多個(gè)按鈕點(diǎn)擊顯示不同內(nèi)容后,怎么讓其內(nèi)容顯示一次,其他的按鈕點(diǎn)擊的內(nèi)容隱藏呢
相關(guān)文章:
1. angular.js - angular內(nèi)容過長展開收起效果2. angular.js - angularjs的自定義過濾器如何給文字加顏色?3. 關(guān)于nginx location配置的問題,root到底是什么4. docker鏡像push報(bào)錯(cuò)5. 關(guān)于docker下的nginx壓力測試6. 大家好,請問在python腳本中怎么用virtualenv激活指定的環(huán)境?7. 并發(fā)模型 - python將進(jìn)程池放在裝飾器里為什么不生效也沒報(bào)錯(cuò)8. python2安裝失敗9. python 怎樣用pickle保存類的實(shí)例?10. python的前景到底有大?如果不考慮數(shù)據(jù)挖掘,機(jī)器學(xué)習(xí)這塊?
排行榜

熱門標(biāo)簽