根据条件更改el-tree的字体颜色

html

:render-content="renderContent" 树节点的内容区的渲染 Function

javascript 复制代码
  <el-tree ref="treeRef" :data="props.data" show-checkbox default-expand-all node-key="label"
                    :check-strictly="checkStrictly" :props="defaultProps" @check-change="handleClick"
                    :default-checked-keys="props.platform" check-on-click-node :filter-node-method="filterNode"  :render-content="renderContent">
                </el-tree>

JS

javascript 复制代码
const renderContent = (h, { node, data, store }) => {
  console.log(data);

  let style = {};
  let label = node.label; // 默认使用节点的标签

//   if (data.hasOwnProperty('isNormal')) {
    if (data.type == '1') {
      style = { fontSize: '14px',color:'red' }; // 设置字体大小
    } else {
      style = { fontSize: '14px',  }; // 设置字体大小和颜色
    }
//   } else {
//     style = { fontSize: '14px' }; // 默认字体大小
//   }

  // 使用 h 函数创建一个 span 元素,并将样式和标签作为属性传递
  return h('span', { style }, label);
}
相关推荐
耶啵奶膘几秒前
uni-app头像叠加显示
开发语言·javascript·uni-app
chéng ௹2 分钟前
uniapp 封装uni.showToast提示
前端·javascript·uni-app
生擒小朵拉17 分钟前
STM32添加库函数
java·javascript·stm32
还有多远.1 小时前
jsBridge接入流程
前端·javascript·vue.js·react.js
w2sfot2 小时前
Passing Arguments as an Object in JavaScript
开发语言·javascript·ecmascript
烛阴2 小时前
【TS 设计模式完全指南】从零到一:掌握TypeScript建造者模式,让你的对象构建链式优雅
javascript·设计模式·typescript
前端Hardy2 小时前
HTML&CSS:有趣的漂流瓶
前端·javascript·css
前端Hardy2 小时前
HTML&CSS :惊艳 UI 必备!卡片堆叠动画
前端·javascript·css
无羡仙3 小时前
替代 Object.freeze 的精准只读模式
前端·javascript
半花3 小时前
【Vue】defineProps、defineEmits 和 defineExpose
前端·vue.js