当前位置:   article > 正文

element ui, el-tree, 自定义图标_el-tree 加图标

el-tree 加图标

template

  1. <el-tree :data="treeData" default-expand-all highlight-current>
  2. <span class="custom-tree-node" slot-scope="{ node }">
  3. <i :class="node.level == 1 ? 'icon1' : node.level == 2 ? 'icon2' : 'icon3'"></i>
  4. <span>{{ node.label }}</span>
  5. </span>
  6. </el-tree>

data

  1. treeData: [
  2. {
  3. id: '',
  4. label: '全部',
  5. level: '1',
  6. children: [{
  7. id: '201',
  8. label: '一级',
  9. level: '2',
  10. children: [{
  11. id: '2011',
  12. label: '二级',
  13. level: '3'
  14. }, {
  15. id: '2012',
  16. label: '二级',
  17. level: '3'
  18. }, {
  19. id: '2013',
  20. label: '二级',
  21. level: '3'
  22. }]
  23. }, {
  24. id: '301',
  25. label: '一级',
  26. level: '2',
  27. }, {
  28. id: '401',
  29. label: '一级',
  30. level: '2',
  31. }]
  32. }
  33. ],

css

  1. .icon1,.icon2,.icon3 {
  2. display: inline-block;
  3. width: 14px;
  4. height: 14px;
  5. }
  6. .icon1 {
  7. background: url("../images/tree/icon1.png") no-repeat;
  8. }
  9. .icon2 {
  10. background: url("../images/tree/icon2.png") no-repeat;
  11. }
  12. .icon3 {
  13. background: url("../images/tree/icon3.png") no-repeat;
  14. }
  15. .is-current > .el-tree-node__content .custom-tree-node > .icon1 {
  16. background: url("../images/tree/icon1-active.png") no-repeat;
  17. }
  18. .is-current > .el-tree-node__content .custom-tree-node > .icon2 {
  19. background: url("../images/tree/icon2-active.png") no-repeat;
  20. }
  21. .is-current > .el-tree-node__content .custom-tree-node > .icon3 {
  22. background: url("../images/tree/icon3-active.png") no-repeat;
  23. }
  24. .is-current > .el-tree-node__content .custom-tree-node > span {
  25. color: #5369de;
  26. }

【参考源】

组件 | Element

声明:本文内容由网友自发贡献,不代表【wpsshop博客】立场,版权归原作者所有,本站不承担相应法律责任。如您发现有侵权的内容,请联系我们。转载请注明出处:https://www.wpsshop.cn/w/人工智能uu/article/detail/1001024
推荐阅读
相关标签
  

闽ICP备14008679号