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": []
}]