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])
            } 
相关推荐
布兰妮甜4 分钟前
单例模式在前端(JavaScript)中的实现与应用
前端·javascript·单例模式
Mintopia4 分钟前
Three.js 加载模型文件:从二进制到像素的奇幻漂流
前端·javascript·three.js
StrongerIrene13 分钟前
rs build 的process.env的值undefined解决方案
开发语言·javascript·ecmascript
前端小巷子23 分钟前
跨域问题解决方案:JSONP
前端·javascript·面试
eric*168831 分钟前
尚硅谷张天禹老师课程配套笔记
前端·vue.js·笔记·vue·尚硅谷·张天禹·尚硅谷张天禹
程序员爱钓鱼1 小时前
Go语言中的反射机制 — 元编程技巧与注意事项
前端·后端·go
GIS之路1 小时前
GeoTools 结合 OpenLayers 实现属性查询(二)
前端·信息可视化
just小千1 小时前
重学React(二):添加交互
javascript·react.js·交互
烛阴1 小时前
一文搞懂 Python 闭包:让你的代码瞬间“高级”起来!
前端·python
AA-代码批发V哥1 小时前
HTML之表单结构全解析
前端·html