element ui tree树节点自定义图标

html

<el-tree :data="data" :props="defaultProps" @node-click="handleNodeClick" :render-content="renderContent"></el-tree>

js

className自己设置

data(){
    return{
        "treeData": [
             {
                 "id": 1,
                 "label": "group",
                 "className": "group-class tree-icon",
                 "children": [
                      {
                          "id": 11,
                           "label": "child",
                          "className": "child-class tree-icon",
                       }
                  ]
             }
         ]
    }
},
methods: {
        renderContent(h, { node, data, store }) {
            return (
              <span>
                <i class={data.className}></i>
                <span>{node.label}</span>
              </span>
              );
          }
  }

css 

.tree-icon {
    display:inline-block;
    ...
 }
.child-class{
    //图标设置
}
.group-class {
    //图标设置
}

 

展开阅读全文

没有更多推荐了,返回首页