Element tree设置默认展开及选中

设置默认展开,将default-expanded-keys的值设为node-key的值对应的数组即可

<el-tree ref="tree" node-key="code" :default-expanded-keys="[1]" :data="treeData" :props="defaultProps"></el-tree>

设置默认选中

this.$nextTick(() => {
    
    
	this.$refs.tree.setCurrentKey(1)
})

注:此处 1 为 treeData 中第一个节点的code,code与 node-key 对应

猜你喜欢

转载自blog.csdn.net/weixin_44640323/article/details/121084774