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>

相关推荐
xxy-mm3 小时前
Javascript 中的继承
开发语言·javascript·ecmascript
1024肥宅5 小时前
手写 EventEmitter:深入理解发布订阅模式
前端·javascript·eventbus
EveryPossible6 小时前
google搜索框
vue.js
3秒一个大6 小时前
HTML5 与 JavaScript 中的二进制数据处理:ArrayBuffer 与 TextEncoder/Decoder 实践
javascript
purpleseashell_Lili7 小时前
如何学习 AG-UI 和 CopilotKit
javascript·typescript·react
LSL666_8 小时前
4 jQuery、JavaScript 作用域、闭包与 DOM 事件绑定
前端·javascript·html
小飞侠在吗8 小时前
vue computed 和 watch
前端·javascript·vue.js
诸葛老刘8 小时前
next.js 框架中的约定的特殊参数名称
开发语言·javascript·ecmascript
毕设十刻9 小时前
基于Vue的考勤管理系统8n7j8(程序 + 源码 + 数据库 + 调试部署 + 开发环境配置),配套论文文档字数达万字以上,文末可获取,系统界面展示置于文末
前端·数据库·vue.js
coding随想9 小时前
掌控选区的终极武器:getSelection API的深度解析与实战应用
java·前端·javascript