Tree 使用插槽,给定 slot-scope="{data}",通过 data 的状态设置节点颜色,slot 有两个参数 data,node
<el-tree
lazy
ref="tree"
node-key="id"
:props="props"
:load="loadNode"
v-if="treeState"
highlight-current
:expand-on-click-node="false"
@current-change="currentChange">
<span slot-scope="{data}" :class="(data.status == 0 || data.status == null) ? 'draft' : data.status == 1 ? 'wait' : data.status == 2 ? 'repulse' : data.status == 3 ? 'audit' : data.status == 4 ? 'pass' : ''">
{{data.label}}
</span>
</el-tree>
<style lang="less">
.draft {
color: #9b968d;
}
.wait {
color: #35aed4;
}
.repulse {
color: rgb(242 45 45);
}
.audit {
color: rgb(242 45 45);
}
.pass {
color: #07c110;
}
</style>