首页 > 其他 > 详细

elementui tree组件自定义图标

时间:2019-07-08 19:29:14      阅读:483      评论:0      收藏:0      [点我收藏+]

~~~

<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,达到显示不同图标的效果 

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

技术分享图片

 

elementui tree组件自定义图标

原文:https://www.cnblogs.com/hellosxs/p/11152851.html

(0)
(0)
   
举报
评论 一句话评论(0
关于我们 - 联系我们 - 留言反馈 - 联系我们:wmxa8@hotmail.com
© 2014 bubuko.com 版权所有
打开技术之扣,分享程序人生!