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])
            } 
相关推荐
剑神一笑2 分钟前
从 JSON.parse 到树形视图:实现一个在线 JSON 格式化工具
前端·javascript·json
淸湫12 分钟前
JavaScript常用正则表达式大全
前端·javascript
脱缰胖虎14 分钟前
vue3+lodash+ts+tailwin 实现多行文本的展开收起代码(支持渲染html)
前端·vue.js
知了清语17 分钟前
我是怎么用 GPT-5.5 分析一个陌生项目源码的
前端
We་ct18 分钟前
LeetCode 64. 最小路径和:动态规划入门实战
开发语言·前端·算法·leetcode·typescript·动态规划
SparkleN.32 分钟前
mini-agent四个问题完善
前端·chrome·github
Dxy123931021638 分钟前
Python设置Excel表格边框样式:从基础到高级
前端·python·excel
布列瑟农的星空1 小时前
tree shaking为什么失效
前端
米丘1 小时前
vue3.5.x 单文件组件(SFC)样式编译过程
css·vue.js·postcss
idcu1 小时前
加入 Lyt.js:从第一行代码到核心贡献者
前端