Element: 树控件中, 没有获取 - 节点相关的方法

Created on 28 Nov 2017  ·  7Comments  ·  Source: ElemeFE/element

在tree组件中, 有 getCheckedNodes, getCheckedKeys 两个方法获取选中的节点, 但是我需要获取节点的子树中有被选中的节点, 也就是 - 节点, 请问怎么获取? 是否有相关的方法获取?

default

Most helpful comment

给tree 一个ref 。然后
let keys = [] let nodesMap = this.$refs.tree.store.nodesMap; const filterChecked = v => { if(nodesMap[v].checked || nodesMap[v].indeterminate){ keys.push(v) } } var nodesKeys=Object.keys(nodesMap) nodesKeys.forEach(filterChecked) console.log(keys)

不管是this.$refs.tree.store 还是this.$refs.tree.root 。里面都可以找到你要的信息

All 7 comments

Hello, this issue has been closed because it does not conform to our issue requirements. Please submit issues with issue-generator. More info can be found in #3693.

楼主有木有解决的办法,我也遇到了这个问题了,而且挺多人提这个问题的,官方都没有给解决的方案么,还是以前给过没有找到?

同求!

同求

同求啊,很多人都碰到这个问题。

这个#1639 可以,我是用这个方法
链接: http://jsfiddle.net/leopoldthecuber/yu2me25j/

给tree 一个ref 。然后
let keys = [] let nodesMap = this.$refs.tree.store.nodesMap; const filterChecked = v => { if(nodesMap[v].checked || nodesMap[v].indeterminate){ keys.push(v) } } var nodesKeys=Object.keys(nodesMap) nodesKeys.forEach(filterChecked) console.log(keys)

不管是this.$refs.tree.store 还是this.$refs.tree.root 。里面都可以找到你要的信息

Was this page helpful?
0 / 5 - 0 ratings