zoukankan      html  css  js  c++  java
  • elementui tree组件自定义图标

    ~~~

    <el-tree
    :data="assetsTreeList"
    :props="assetsProps"
    node-key="id"
    :show-checkbox=this.checkFlag
    :default-checked-keys=this.roleAssetsCheckList
    >
    <span class="custom-tree-node" slot-scope="{ node, data }">
    <span :dataType="data.type">
    <i :class="data.checkIcon"></i>
    <i :class="data.iconSkin"></i>
    {{ node.label }}
    </span>
    </span>
    </el-tree>

    ~~~

    ~~~

    export default {
    name: "demo",
    data(){
    return {
    assetsTreeList: [
    {
    "name": "基础",
           "keyCode": "ATS_BASE_V",
           "type": "1",
           "typeTxt": "添加",
           "function": "0",
           "code": "D0201001",
           "dataResourceTree": [{
    "name": "编辑",
             "parentID": "D0201001",
             "keyCode": "ATS_BASE_E",
             "type": "2",
             "function": "0",
             "code": "D0201002",
             "dataResourceTree": [],
             "id": "D0201002"
          }],
          "id": "D0201001"
        },
        {
    "name": "位置",
          "keyCode": "ATS_LOCA_V",
          "type": "1",
          "typeTxt": "添加",
          "function": "0",
          "code": "D0202001",
          "dataResourceTree": [{
    "name": "编辑",
            "parentID": "D0202001",
            "keyCode": "ATS_LOCA_E",
            "type": "2",
            "function": "0",
            "code": "D0202002",
            "dataResourceTree": [],
            "id": "D0202002"
          }],
          "id": "D0202001"
        },
       ],
      }
    }
    }

    ~~~

    在对树结构进行渲染的时候使用slot-scope,根据结构数据中iconSkin对应的值不同,设置不同的class,达到显示不同图标的效果 

    下面 的效果是是我真实数据渲染的,上面的假数据 结构一样

  • 相关阅读:
    web第一章(html)
    面向对象第七章,内存的管理,面向对象三大特征封装、继承、多态
    面向对象第六章(接口、强转、多态)
    面向对象第五章(封装、抽象类、匿名内部类)
    面向对象第四章(封装、static)
    面向对象第二章(引用类型数组、继承)
    python 生成随机数
    python 生成测试报告
    python 邮件发送
    python 日志打印
  • 原文地址:https://www.cnblogs.com/hellosxs/p/11152851.html
Copyright © 2011-2022 走看看