Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Tree选中项 #1709

Closed
longhuasishen opened this issue May 16, 2016 · 3 comments
Closed

Tree选中项 #1709

longhuasishen opened this issue May 16, 2016 · 3 comments

Comments

@longhuasishen
Copy link

Tree获取选中项时,能否把选中项的父节点以及父节点的父节点全部获取,比如三级菜单,最后一级叶子节点选中后,获取选中项前面2项获取不到

@warmhug
Copy link
Contributor

warmhug commented May 16, 2016

let sel = [];
function findPath(selected, children, parent = { root: true }) {
  for (var i = 0; i < children.length; i++) {
    const item = children[i];
    if (selected === item.key) {
      sel.push(item);
      return;
    }
    if (item.children) {
      findPath(selected, item.children, item);
      if (sel.length) {
        sel.push(item);
        return;
      }
    }
  }
}

@superRaytin
Copy link
Contributor

问题解决了吗?先关闭

@lock
Copy link

lock bot commented May 5, 2018

This thread has been automatically locked because it has not had recent activity. Please open a new issue for related bugs and link to relevant comments in this thread.

@lock lock bot locked as resolved and limited conversation to collaborators May 5, 2018
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
Development

No branches or pull requests

3 participants