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])
            } 
相关推荐
洋不写bug2 分钟前
前端html基础标签
前端·html
GISer_Jing11 分钟前
前端学习总结——AI&主流前沿方向篇
前端·人工智能·学习
渣哥20 分钟前
用错注入方式?你的代码可能早就埋下隐患
javascript·后端·面试
尘世中一位迷途小书童22 分钟前
Monorepo 工具大比拼:为什么我最终选择了 pnpm + Turborepo?
前端·架构
一枚前端小能手23 分钟前
🔍 重写vue之ref和reactive
前端·javascript·vue.js
星链引擎25 分钟前
4sapi.com开发者进阶版(技术导向,侧重 “原理 + 最佳实践”)
前端
尘世中一位迷途小书童27 分钟前
2025年了,你还在用传统的多仓库管理吗?Monorepo 架构深度解析
前端·架构
fruge30 分钟前
前端性能优化实践指南:从理论到落地
前端·性能优化
快起来别睡了34 分钟前
用这 9 个 API,我把页面性能干到了 90+
前端
芒果茶叶1 小时前
深入浅出requestAnimationFrame
前端·javascript·html