Vue根据后端返回结果转换成不同的展示效果的三种方式
方式一:
<el-table-column
prop="tagType"
label="标签类型"
width="120"
:formatter="tagTypeFormatter">
</el-table-column>
tagTypeFormatter(row) {
let tagType = row.tagType;
if (tagType === '0') {
return '情况1';
} else if (tagType === '1') {
return '情况2';
}
}
方式二:
<el-table-column prop="type" label="类型" align="center">
<template v-slot="{ row }">
<span v-show="row.type == 1">普通用户</span>
<span v-show="row.type == 2">管理员</span>
<span v-show="row.type == 3">项目经理</span>
</template>
</el-table-column>
方式三:
<el-table-column prop="tagClass" label="标签分类" width="120">
<template slot-scope="scope">
<span>{{ classFormat(scope.row.tagClass, getTagClass) }}</span>
</template>
</el-table-column>
getTagClass: [
{ dictValue: '01', dictLabel: '政策因素' },
{ dictValue: '02', dictLabel: '用电行为因素' },
{ dictValue: '03', dictLabel: '线损状态' },
{ dictValue: '04', dictLabel: '技术因素' },
{ dictValue: '05', dictLabel: '运行指标因素' },
{ dictValue: '06', dictLabel: '客户服务' },
{ dictValue: '07', dictLabel: '台区设备' },
{ dictValue: '08', dictLabel: '地理环境' }
]
classFormat(row, obj) {
let filter = obj.filter(res => res.dictValue === row);
return filter[0]?.dictLabel;
},
【推荐】国内首个AI IDE,深度理解中文开发场景,立即下载体验Trae
【推荐】编程新体验,更懂你的AI,立即体验豆包MarsCode编程助手
【推荐】抖音旗下AI助手豆包,你的智能百科全书,全免费不限次数
【推荐】轻量又高性能的 SSH 工具 IShell:AI 加持,快人一步
· 阿里最新开源QwQ-32B,效果媲美deepseek-r1满血版,部署成本又又又降低了!
· 单线程的Redis速度为什么快?
· SQL Server 2025 AI相关能力初探
· AI编程工具终极对决:字节Trae VS Cursor,谁才是开发者新宠?
· 展开说说关于C#中ORM框架的用法!