文章详情页
javascript - 一个vuex的问题
浏览:122日期: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. css - 移动端 line-height安卓错位,苹果机正常用,缩放解决了,可是又出来了占位的问题2. mysql begin work语句是干嘛的?3. javascript - 移动端css动画播放状态暂停在ios不起作用 animation-play-state4. node.js - 函数getByName()中如何使得co执行完后才return5. javascript - vue $set 整个数组6. docker-compose中volumes的问题7. 微信开放平台 - ios APP能不能打开微信然后通过微信跳转到指定的URL?8. 小程序怎么加外链,语句怎么写!求救新手,开文档没发现9. 新手 - Python 爬虫 问题 求助10. Mac环境下QT编译MySQL驱动屡次失败?如何?
排行榜
