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])
            } 
相关推荐
EveryPossible21 分钟前
google搜索框
vue.js
海市公约1 小时前
HTML网页开发从入门到精通:从标签到表单的完整指南
前端·ide·vscode·程序人生·架构·前端框架·html
3秒一个大1 小时前
HTML5 与 JavaScript 中的二进制数据处理:ArrayBuffer 与 TextEncoder/Decoder 实践
javascript
purpleseashell_Lili2 小时前
如何学习 AG-UI 和 CopilotKit
javascript·typescript·react
行云流水6262 小时前
前端树形结构实现勾选,半勾选,取消勾选。
前端·算法
diudiu_332 小时前
web漏洞--认证缺陷
java·前端·网络
阿珊和她的猫2 小时前
<video>` 和 `<audio>` 标签的常用属性解析
前端
LSL666_3 小时前
4 jQuery、JavaScript 作用域、闭包与 DOM 事件绑定
前端·javascript·html
yinuo3 小时前
前端跨页面通讯终极指南⑤:window.name 用法全解析
前端
小飞侠在吗3 小时前
vue computed 和 watch
前端·javascript·vue.js