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>

相关推荐
FungLeo1 小时前
成为全栈·Vue 管理后台篇·Vue3 + Vite + Naive UI:后台工程基座怎么搭
前端·vue.js·ui·typescript·vite·前端工程化·biome
云上工程笔记2 小时前
SRT字幕一键转手绘动画:srt-whiteboard-animation的复刻实录
大数据·开发语言·javascript·人工智能·机器学习
FungLeo2 小时前
成为全栈·Vue管理后台篇·<scriptsetup>:把页面拆成可读、可测的 Vue 组件
前端·javascript·vue.js·typescript·前端组件化·composition api·vue sfc
清晨Coding15 小时前
删了 Cookie 还能自动登录?Google系网站登录态自动恢复的原理分析
javascript
kyriewen15 小时前
我扫了 814 个依赖,97 个还敢要 Node 10
前端·javascript·程序员
程序员大阳16 小时前
HTML+CSS+JS对话式实战(9)-项目总结与问题分析
javascript·css·html·实战·项目总结
Hilaku17 小时前
MCP 协议会成为前端 AI 工程的标准接口吗?
前端·javascript·程序员
RobinDevNotes20 小时前
从 Electron 到 GPUI,9 个跨平台桌面方案该怎么选
前端·javascript·rust·electron·openresty·前端开发工具
软件技术NINI20 小时前
基于SpringBoot和Vue的新能源汽车销售推荐系统
java·vue.js·spring boot·后端·汽车·毕业设计·毕设
程序员大阳20 小时前
HTML+CSS+JS对话式实战(6)-学生端查看活动功能开发
javascript·css·html·模块·查看学生