文章詳情頁
javascript - 一個vuex的問題
瀏覽:143日期: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. java - spring-data Jpa 不需要執行save 語句,Set字段就可以自動執行保存的方法?求解2. html5 - 微信瀏覽器視頻播放失敗3. javascript - 這問題怎么處理額4. html - 這種錯位的時間軸怎么布局,然后用css實現?5. 網頁爬蟲 - Python 爬蟲中如何處理驗證碼?6. javascript - jQuery中live事件在移動微信端下沒有效果;代碼如下7. javascript - SuperSlide.js火狐不兼容怎么回事呢8. javascript - owl.carousel.js這個插件的原作者的網址是多少了?9. phpstady在win10上運行10. 在應用配置文件 app.php 中找不到’route_check_cache’配置項
排行榜
