Element-ui框架Tree树形控件切换高亮显示选中效果

废话不多说,直接上代码
1 <template>
2 <div class="warpper">
3 <el-tree ref="tree" :data="TreeData" node-key="id" :key="treeKey" current-node-key :props="defaultProps" highlight-current @node-click="handleNodeClick"></el-tree>
4 </div>
5 </template>
6
7 <script>
8 export default {
9 data() {
10 return {
11 ParmentData: null,
12 TreeData: [
13 {
14 id: 1,
15 label: '一级 1',
16 children: [
17 {
18 id: 4,
19 label: '二级 1-1',
20 children: [
21 { id: 9, label: '三级 1-1-1' },
22 { id: 10, label: '三级 1-1-2' }
23 ]
24 }
25 ]
26 }, {
27 id: 2,
28 label: '一级 2',
29 children: [
30 {
31 id: 5,
32 label: '二级 2-1'
33 }, {
34 id: 6,
35 label: '二级 2-2'
36 }
37 ]
38 }, {
39 id: 3,
40 label: '一级 3',
41 children: [
42 {
43 id: 7,
44 label: '二级 3-1'
45 }, {
46 id: 8,
47 label: '二级 3-2'
48 }
49 ],
50 show: true
51 }],
52 defaultProps: {
53 children: 'children',
54 label: 'label'
55 },
56 treeKey:'',
57 }
58 },
59 created() {
60 this.$nextTick(function(){
61 this.$data.TreeData.forEach(row => {
62 if(row.show){
63 this.$refs.tree.setCurrentKey(row.id);
64 this.$refs.tree.store.nodesMap[row.id].expanded = true;
65 }
66 })
67 })
68 },
69 methods: {
70 handleNodeClick: function (data,checked) {
71 // 点击事件
72 },
73 handleCheckChange(data, checked, indeterminate) {
74 console.log(data, checked, indeterminate);
75 },
76 }
77 }
78 </script>
79
80 <style scoped>
81 .warpper .el-tree--highlight-current /deep/ .el-tree-node.is-checked > .el-tree-node__content {
82 background-color: rgb(255, 255, 255);
83 color:rgb(64, 158, 255);
84 }
85 .warpper .el-tree--highlight-current /deep/ .el-tree-node.is-current > .el-tree-node__content {
86 background-color: rgb(255, 255, 255);
87 color:rgb(64, 158, 255);
88 }
89 </style>
顺便为大家推荐好听的歌曲

Element-ui框架Tree树形控件切换高亮显示选中效果的更多相关文章
- Element ui 使用 Tree 树形控件
使用树形控件需要映入 jsx才能运行链接:https://github.com/vuejs/babel-plugin-transform-vue-jsx#usage npm install\ babe ...
- Element ui tree树形控件获取当前节点id和父节点id
低版本Element ui tree树形控件获取当前节点id和父节点id的方法:点击查看 最新版本Element ui tree树形控件获取当前节点id和父节点id教程: 1.找到node_modul ...
- vue+element-ui之tree树形控件有关子节点和父节点之间的各种选中关系详解
做后端管理系统,永远是最蛋疼.最复杂也最欠揍的事情,也永远是前端开发人员最苦逼.最无奈也最尿性的时刻.蛋疼的是需求变幻无穷,如同二师兄的三十六般变化:复杂的是开发难度寸步难行,如同蜀道难,难于上青天: ...
- vue_elementUI_ tree树形控件 获取选中的父节点ID
el-tree 的 this.$refs.tree.getCheckedKeys() 只可以获取选中的id 无法获取选中的父节点ID想要获取选中父节点的id;需要如下操作1. 找到工程下的node_m ...
- ElementUI Tree树形控件renderContent return时报错
问题描述: 使用Tree树形控件使用render-content渲染时return后报错或npm run dev时候报错,报错信息相同,如下: 问题分析: renderContent函数中需要使用js ...
- BootstrapBlazor实战 Tree树形控件使用(2)
继续上篇实战BootstrapBlazor树型控件Tree内容, 本篇主要讲解整合Freesql orm快速制作数据库后台维护页面 demo演示的是Sqlite驱动,FreeSql支持多种数据库,My ...
- BootstrapBlazor实战-Tree树形控件使用(1)
实战BootstrapBlazor树型控件Tree的使用, 以及整合Freesql orm快速制作数据库后台维护页面 demo演示的是Sqlite驱动,FreeSql支持多种数据库,MySql/Sql ...
- vue-element Tree树形控件通过id默认选中
一.设置 1.给树形控件设置 ref="tree" node-key="id" 2.在获取数据的位置加上 this.$nextTick(() => { t ...
- easyui Tree树形控件的异步加载
Tree控件 $('#partyOrgTree').tree({ checkbox: false, url: getDataUrl, onClick: function (node) { getDiv ...
- js ui框架 My97日期控件 富文本编辑器
My97日期控件 http://www.my97.net/dp/index.asp 富文本编辑器 http://www.kindsoft.net/demo.php 百度的magic也不错 http:/ ...
随机推荐
- PHP 静态延迟绑定 static
PHP (self static parent 区别) self调用的方法和属性始终表示当前类的方法和属性 static调用的方法和属性为当前执行的类的方法和属性 parent调用的方法和属性为父类的 ...
- TS补充笔记
TS掘金笔记:https://juejin.cn/post/6872111128135073806 *为疑惑点 类型总结: 2.6.1Enum类型数字枚举设置初始值: 2.6.1.1给第一个枚举 ...
- CMake配置跨平台项目踩的坑
当要在windows平台下使用MinGW作为cmake使用的make平台时,需要确保cmake能够在系统环境变量PATH中找到MinGW的bin目录,如果PATH中没有MinGW的话可以在CMakeL ...
- git切换到某个tag
git checkout tags/some_tag_name -b a_new_branch_name
- jdbc与Statement接口
Statement接口引入 使用Statement接口实现添加数据操作 使用Statement接口实现更新数据操作 使用Statement接口实现删除数据操作
- CDO学习2 CDO 入门教程Tutorial
#20210117#注:如果需要用cdo对数据进行截取,可参考buguse的几篇博文: 如何利用CDO从数据集中提取数据 CDO条件性选择数据 - 云+社区 - 腾讯云 CDO转换数据集格式 - 云+ ...
- Word List 2023
Word List 2023 记录 2023 年阅读论文时遇到的单词 wildcard 通配符 wildcard predicate 通配符谓词 maturation 成年过程:长大成人 ever-i ...
- windows环境下部署项目
有些时候,我们的项目不得不用windows服务器部署,但是需要注意的是,windows服务是无法开启多进程处理请求的. 本文介绍如何在windows上部署flask项目,应用 apache + mod ...
- sql server 与mysql差异(innodb)
MySQL SQL SERVER CHAR_LENGTH(str) LEN(character_expression) CONCAT(str1,str2,...) str1+str2 INSERT(s ...
- Pytorch Dropout函数
Dropout layers class torch.nn.Dropout(p=0.5, inplace=False) 随机将输入张量中部分元素设置为0.对于每次前向调用,被置0的元素都是随机的. 参 ...