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])
            } 
相关推荐
yinuo2 小时前
前端跨页面通讯终极指南⑥:SharedWorker 用法全解析
前端
PineappleCoder7 小时前
还在重复下载资源?HTTP 缓存让二次访问 “零请求”,用户体验翻倍
前端·性能优化
拉不动的猪7 小时前
webpack编译中为什么不建议load替换ast中节点删除consolg.log
前端·javascript·webpack
李姆斯7 小时前
Agent时代下,ToB前端的UI和交互会往哪走?
前端·agent·交互设计
源码获取_wx:Fegn08957 小时前
基于springboot + vue健身房管理系统
java·开发语言·前端·vue.js·spring boot·后端·spring
闲谈共视7 小时前
基于去中心化社交与AI智能服务的Web钱包商业开发的可行性
前端·人工智能·去中心化·区块链
CreasyChan7 小时前
C# 反射详解
开发语言·前端·windows·unity·c#·游戏开发
JIngJaneIL8 小时前
基于Java+ vue智慧医药系统(源码+数据库+文档)
java·开发语言·前端·数据库·vue.js·spring boot
+VX:Fegn08958 小时前
计算机毕业设计|基于springboot + vue图书管理系统(源码+数据库+文档)
数据库·vue.js·spring boot·后端·课程设计
阿蒙Amon9 小时前
JavaScript学习笔记:6.表达式和运算符
javascript·笔记·学习