{"action":"closed","issue":{"url":"https://api.github.com/repos/ElemeFE/element/issues/13237","repository_url":"https://api.github.com/repos/ElemeFE/element","labels_url":"https://api.github.com/repos/ElemeFE/element/issues/13237/labels{/name}","comments_url":"https://api.github.com/repos/ElemeFE/element/issues/13237/comments","events_url":"https://api.github.com/repos/ElemeFE/element/issues/13237/events","html_url":"https://github.com/ElemeFE/element/issues/13237","id":375464963,"node_id":"MDU6SXNzdWUzNzU0NjQ5NjM=","number":13237,"title":"tree组件的default-expanded-keys","user":{"login":"jinmarcus","id":17996289,"node_id":"MDQ6VXNlcjE3OTk2Mjg5","avatar_url":"https://avatars3.githubusercontent.com/u/17996289?v=4","gravatar_id":"","url":"https://api.github.com/users/jinmarcus","html_url":"https://github.com/jinmarcus","followers_url":"https://api.github.com/users/jinmarcus/followers","following_url":"https://api.github.com/users/jinmarcus/following{/other_user}","gists_url":"https://api.github.com/users/jinmarcus/gists{/gist_id}","starred_url":"https://api.github.com/users/jinmarcus/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/jinmarcus/subscriptions","organizations_url":"https://api.github.com/users/jinmarcus/orgs","repos_url":"https://api.github.com/users/jinmarcus/repos","events_url":"https://api.github.com/users/jinmarcus/events{/privacy}","received_events_url":"https://api.github.com/users/jinmarcus/received_events","type":"User","site_admin":false},"labels":[{"id":936023013,"node_id":"MDU6TGFiZWw5MzYwMjMwMTM=","url":"https://api.github.com/repos/ElemeFE/element/labels/invalid","name":"invalid","color":"d32844","default":true}],"state":"closed","locked":false,"assignee":null,"assignees":[],"milestone":null,"comments":1,"created_at":"2018-10-30T12:31:39Z","updated_at":"2018-10-30T12:31:41Z","closed_at":"2018-10-30T12:31:41Z","author_association":"NONE","body":"Element UI version\r\n2.4.9\r\n\r\nOS/Browsers version\r\nwin10/ chrome\r\n\r\nVue version\r\n2.5.16\r\n\r\nReproduction Link\r\nhttps://jsfiddle.net/turai/em76khbc/72/\r\n\r\nSteps to reproduce\r\n\r\n\r\nWhat is Expected?\r\n\r\n\r\nWhat is actually happening?\r\n\r\ntree组件的default-expanded-keys方法 展开有效， 收起无效，请看看是不是bug\r\n```\r\n<template> <el-tree ref=\"tree\" :data=\"tree\" :default-expanded-keys=\"expand\" node-key=\"id\" ></el-tree> </template>\r\n\r\nexport default { data() { return { // 树数据 tree: {...}, expand: [] } },\r\n\r\nmethods: {\r\n  /**\r\n     * 全部树节点展开  (可以展开数组中的树节点)\r\n     */\r\n    nodeExpandAll() {\r\n        this.expand = [1,2,3,4]\r\n    },\r\n\r\n    /**\r\n     * 全部树节点收起 （当执行了全部展开后，再收起，这样是无效的，请看看是不是bug）\r\n     */\r\n    nodeCollapseAll() {\r\n        this.expand = [1]\r\n    },\r\n} }\r\n```\r\n\r\n 我目前只能在全部收起的时候，采用下面的折中办法\r\n```\r\n   /**\r\n     * 全部树节点收起 （但是这样是有效的，只是这样的方法，太迂回了）\r\n     */\r\n    nodeCollapseAll() {\r\n        this.expand.forEach((key) => {\r\n                const node = this.$refs.tree.getNode(key)\r\n                if (node) {\r\n                    node.expanded = false\r\n                }\r\n        })\r\n    },\r\n```"}}
{"actor":{"display_login":"element-bot"}}