vue3中el-tree设置默认选中节点和展开节点

1.el-tree设置 node-key,current-node-key,default-expanded-keys,highlight-current:

html 复制代码
<el-tree 
ref="taskTree" 
:data="ptreeData"
node-key="key"
:current-node-key="currentKey" 
:default-expanded-keys="defaultExpanded" 
highlight-current>
</el-tree>

2.赋值数据

html 复制代码
 nextTick(() => {
            currentKey.value=firstNode.key;
            taskTree.value.setCurrentKey(firstNode.key);
            defaultExpanded.value=nodeIds;
 })

注意:使用了nextTick。

相关推荐
reasonsummer3 分钟前
【办公类-133-02】20260319_学区化展示PPT_02_python(图片合并文件夹、提取同名图片归类文件夹、图片编号、图片GIF)
前端·数据库·powerpoint
胡耀超18 分钟前
Web Crawling 网络爬虫全景:技术体系、反爬对抗与全链路成本分析
前端·爬虫·python·网络爬虫·数据采集·逆向工程·反爬虫
阿明的小蝴蝶22 分钟前
记一次Gradle环境的编译问题与解决
android·前端·gradle
Ruihong24 分钟前
【VuReact】轻松实现 Vue 到 React 路由适配
前端·react.js
山_雨25 分钟前
startViewTransition
前端
写代码的【黑咖啡】28 分钟前
Python Web 开发新宠:FastAPI 全面指南
前端·python·fastapi
凉_橙28 分钟前
gitlab CICD
前端
wangfpp30 分钟前
性能优化,请先停手:为什么我劝你别上来就搞优化?
前端·javascript·面试
踩着两条虫32 分钟前
AI 驱动的 Vue3 应用开发平台 深入探究(二十):CLI与工具链之构建配置与Vite集成
前端·vue.js·ai编程
凉_橙33 分钟前
前端项目与node项目部署记录
前端