当前位置:   article > 正文

element el-tree current-node-key无效 setCurrentKey()无效_el-tree setcurrentnode

el-tree setcurrentnode

element el-tree current-node-key无效 setCurrentKey()无效

可以结合 current-node-key属性和this.$refs['treeRef'].setCurrentKey()方法及this.$nexTick()同时使用

代码如下

<el-tree
	ref="treeRef"
	node-key="id"
	:data="list"
	:current-node-key="currentKey"
><el-tree>
  • 1
  • 2
  • 3
  • 4
  • 5
  • 6

js:

created(){
	this.list=[数据]
	this.$nextTick(()=>{
		this.currentKey=this.list[0].id
		this.$refs['treeRef'].setCurrentKey(this.currentKey)
	})
}
  • 1
  • 2
  • 3
  • 4
  • 5
  • 6
  • 7
声明:本文内容由网友自发贡献,不代表【wpsshop博客】立场,版权归原作者所有,本站不承担相应法律责任。如您发现有侵权的内容,请联系我们。转载请注明出处:https://www.wpsshop.cn/w/神奇cpp/article/detail/830723
推荐阅读
相关标签
  

闽ICP备14008679号