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])
            } 
相关推荐
王同学_1162 分钟前
爬虫辅助技术(css选择器、xpath、正则基础语法)
前端·css·爬虫
Irene19916 分钟前
创建新DOM节点方式总结
javascript·dom
2501_9462338917 分钟前
Flutter与OpenHarmony大师详情页面实现
android·javascript·flutter
牛先森家的牛奶24 分钟前
elementUI的table合并行和列模板
前端·javascript·elementui
En^_^Joy26 分钟前
CSS常用属性速查手册
前端·css
Bigger28 分钟前
踩坑记:NPM 发布脚本导致组件重复发布
前端·ci/cd·npm
Hao_Harrision30 分钟前
50天50个小项目 (React19 + Tailwindcss V4) ✨ | AutoTextEffect(自动打字机)
前端·typescript·react·tailwindcss·vite7
IT_陈寒34 分钟前
Vite 3.0 实战:5个优化技巧让你的开发效率提升50%
前端·人工智能·后端
玲小珑1 小时前
React 防抖函数中的闭包陷阱与解决方案
前端·react.js
咖啡の猫1 小时前
TypeScript编译选项
前端·javascript·typescript