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>

相关推荐
DevUI团队1 天前
Angular开发者必看:深度解析单元测试核心技巧与最佳实践
前端·javascript·angular.js
q***64971 天前
SpringMVC 请求参数接收
前端·javascript·算法
悟能不能悟1 天前
<style scoped>vue中怎么引用css文件
css·vue.js
向葭奔赴♡1 天前
若依系统权限控制全流程解析
前端·javascript·vue.js·ruoyi·navicat
u***u6851 天前
Vue虚拟现实案例
前端·vue.js·vr
艾小码1 天前
Vue 3 defineProps 与 defineEmits 深度解析
前端·javascript·vue.js
前端炒粉1 天前
35.LRU 缓存
开发语言·javascript·数据结构·算法·缓存·js
lumi.1 天前
Vue + Element Plus 实现AI文档解析与问答功能(含详细注释+核心逻辑解析)
前端·javascript·vue.js·人工智能
S***t7141 天前
Vue面试经验
javascript·vue.js·面试
粉末的沉淀1 天前
css:制作带边框的气泡框
前端·javascript·css