文章詳情頁
javascript - 一個vuex的問題
瀏覽:201日期: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 - 多個按鈕點(diǎn)擊顯示不同內(nèi)容后,怎么讓其內(nèi)容顯示一次,其他的按鈕點(diǎn)擊的內(nèi)容隱藏呢
相關(guān)文章:
1. 關(guān)于docker下的nginx壓力測試2. docker - 各位電腦上有多少個容器啊?容器一多,自己都搞混了,咋辦呢?3. mac里的docker如何命令行開啟呢?4. 關(guān)docker hub上有些鏡像的tag被標(biāo)記““This image has vulnerabilities””5. nignx - docker內(nèi)nginx 80端口被占用6. docker容器呢SSH為什么連不通呢?7. dockerfile - 我用docker build的時候出現(xiàn)下邊問題 麻煩幫我看一下8. docker-compose 為何找不到配置文件?9. docker start -a dockername 老是卡住,什么情況?10. angular.js使用$resource服務(wù)把數(shù)據(jù)存入mongodb的問題。
排行榜

熱門標(biāo)簽
網(wǎng)公網(wǎng)安備