element el-tree 添加图标

it2024-09-30  17

1、指定渲染函数:render-content="renderContent"

<el-tree ref="tree" :data="functionData" :props="props" accordion :default-checked-keys="selectFunction" show-checkbox node-key="id" :render-content="renderContent"></el-tree> 2、根据自己需要配置选项 props: { children: 'children', label: 'name' } 3、实现渲染函数 renderContent (h, { node, data, store }) { return ( <span> <i class={data.icon}></i> <span> {node.label}</span> </span> ) } 4、数据源格式 "treeData": [   {      "id": 1,   "name": "group",   "icon": "el-icon-menu",   "children": []   }]

转载于:https://www.cnblogs.com/zqyw/p/10406348.html

最新回复(0)