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])
            } 
相关推荐
Wect9 小时前
React 更新触发原理详解
前端·react.js·面试
cxxcode9 小时前
Web 帧渲染与 DOM 准备
前端
光影少年9 小时前
React Hooks的理解?常用的有哪些?
前端·react.js·掘金·金石计划
大鸡爪9 小时前
Vue3 组件库实战(七):从本地到 NPM:版本管理与自动化发布指南(下)
前端·vue.js
幸福摩天轮9 小时前
记录commonjs的一道面试题
前端
qq_406176149 小时前
详解Vue中的计算属性(computed)和观察属性(watch)
开发语言·前端·javascript·vue.js·前端框架
kyriewen9 小时前
Grid 网格布局:二维世界的布局王者,像下围棋一样掌控页面
前端·css·html
顽固_倔强9 小时前
Vue2 与 Vue3 对比:从 Options API 到 Composition API 的演进
前端·面试
巫山老妖9 小时前
用 OpenClaw 每日自动发布 AI 速递:微信公众号 + 小红书全流程实操
前端
兆子龙9 小时前
V8 与 JavaScript 执行:从字节码、Ignition 到 TurboFan JIT 的完整管线
前端