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])
            } 
相关推荐
2301_773643625 分钟前
ceph镜像
前端·javascript·ceph
程序员黑豆26 分钟前
AI全栈开发之Java:什么是JDK
前端·后端·ai编程
To_OC27 分钟前
万字解析《JS语言精粹》之第四章:函数15大核心精髓(JS灵魂核心)
前端·javascript·代码规范
宋拾壹30 分钟前
同时添加多个类目
android·开发语言·javascript
IT知识分享35 分钟前
从零开发在线简繁转换工具:OpenCC 实战、避坑经验与方案选型
javascript·python
mqcode37 分钟前
Vue3 + Element Plus + Vite 企业级后台框架搭建全流程
前端
SL-staff39 分钟前
Web 白板技术架构深度解析:从渲染到协作的选型哲学
前端·架构
川冰ICE42 分钟前
JavaScript实战④|天气查询应用,调用API与异步处理
javascript·css·css3
微扬嘴角42 分钟前
react篇4--setState、LazyLoad和Hooks
前端·javascript·react.js
杨梦馨1 小时前
万级数据表格卡死?Web Worker 一招搞定
前端·javascript·vue.js