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>

相关推荐
学习星球8 小时前
Solid.js 实战:拆解官方 RealWorld 项目
开发语言·javascript·vue.js
YuJie10 小时前
JSBridge 基础知识
前端·javascript
默_笙10 小时前
🍕 后端接口还没写好,前端已经跑起来了?Mock 数据 + axios 接口层,前后端再也不互相"等"
前端·javascript
爱勇宝10 小时前
客户只想看个页面,我却做了一个静态演示发布系统
前端·javascript·后端
界面开发小八哥13 小时前
界面控件DevExpress Blazor v26.1新版亮点 - Navigation(导航)
javascript·.net·界面控件·blazor·devexpress·ui开发
aXin_ya14 小时前
ElementUI (01):Vue2 项目引入 ElementUI使用
elementui·vue
SendTomo14 小时前
send.wang(私传网)基于网页P2P直连传输大文件的优势
javascript·网络·webrtc·html5·p2p
学习星球15 小时前
Astro 全栈实战:拆解 RealWorld 项目
前端·javascript·架构·系统架构·前端框架·c5全栈
尚可签15 小时前
基于 Spring Boot + Vue 的 AI 智能在线订餐系统
vue.js·人工智能·spring boot
张元清16 小时前
React useTimeout Hook:声明式 setTimeout 与自动清理 (2026)
javascript·react.js