VUE+ Element-plus , el-tree 修改默认左侧三角图标,并使没有子级的那一项不展示图标

<template>

<el-tree

:data="data"

:props="defaultProps"

:render-content="renderContent"

accordion

/>

</template>

<script>

export default {

data() {

return {

data: [

{

label: 'Parent 1',

children: [

{

label: 'Child 1-1'

},

{

label: 'Child 1-2'

}

]

},

{

label: 'Parent 2'

},

{

label: 'Parent 3',

children: [

{

label: 'Child 3-1'

}

]

}

],

defaultProps: {

children: 'children',

label: 'label'

}

}

},

methods: {

renderContent(h, { node, data }) {

return (

<span>

{node.isLeaf ? (

// No icon for leaf nodes

<span>{data.label}</span>

) : (

// Custom icon for nodes with children

<i class="el-icon-arrow-right" style="margin-right: 8px;"></i>

)}

{data.label}

</span>

)

}

}

}

</script>

<style scoped>

/* Custom icon styling, if needed */

.el-icon-arrow-right {

color: blue;

}

</style>

相关推荐
阿蓝灬13 分钟前
clientWidth vs offsetWidth
前端·javascript
用户904438163246038 分钟前
从40亿设备漏洞到AI浏览器:藏在浏览器底层的3个“隐形”原理
前端·javascript·浏览器
鸡吃丸子1 小时前
React Native入门详解
开发语言·前端·javascript·react native·react.js
阿蒙Amon1 小时前
JavaScript学习笔记:12.类
javascript·笔记·学习
JIngJaneIL1 小时前
基于Java+ vue图书管理系统(源码+数据库+文档)
java·开发语言·前端·数据库·vue.js·spring boot·后端
阿蒙Amon1 小时前
JavaScript学习笔记:10.集合
javascript·笔记·学习
VX:Fegn08951 小时前
计算机毕业设计|基于springboot + vue考勤管理系统(源码+数据库+文档)
数据库·vue.js·spring boot·后端·课程设计
一 乐2 小时前
幼儿园管理|基于springboot + vue幼儿园管理系统(源码+数据库+文档)
java·数据库·vue.js·spring boot·后端
JIngJaneIL2 小时前
基于Java + vue校园论坛系统(源码+数据库+文档)
java·开发语言·前端·数据库·vue.js·spring boot·后端
馬致远2 小时前
Vue TodoList 待办事项小案例(代码版)
前端·javascript·vue.js