el-tree树状控件如何定位到选中的节点的位置
作者:言666
这篇文章主要介绍了el-tree树状控件如何定位到选中的节点的位置,本文通过示例代码给大家介绍的非常详细,感兴趣的朋友跟随小编一起看看吧
效果图

在el-tree 控件加 :render-content="renderContent"

在掉接口的方法中

实际有用的是setTimeout 方法和this.$refs.xxxxxx.setCheckedKeys([industrycodeList])
if(res.data.swindustrylist.length>0){
res.data.swindustrylist.forEach(item => {
industrycodeList.push(item.industrycode)
setTimeout(() => {
const currentDom = document.querySelector('#A' + item.industrycode)
console.log('industrycodeList',industrycodeList)
console.log('item.industrycode',item.industrycode)
if (currentDom) {
currentDom.scrollIntoView()
}
}, 1000)
})
this.$refs.mappTree.setCheckedKeys([industrycodeList])
} 到此这篇关于el-tree树状控件定位到选中的节点的位置的文章就介绍到这了,更多相关el-tree定位到选中的节点的位置内容请搜索脚本之家以前的文章或继续浏览下面的相关文章希望大家以后多多支持脚本之家!
