普通写法,使用三目运算符 :
html:
<el-table
ref="multipleTable"
:data="orderActivityListVOS"
tooltip-effect="dark"
style="width: 100%"
@selection-change="handleSelectionChange"
>
<el-table-column
prop="useType"
label="使用条件"
width="100"
>
<template slot-scope="scope">
{{
scope.row.useType== 1
? "无限制"
: scope.row.useType== 2
? "满减"
: "—"
}}
</template>
</el-table-column>
</el-table>
进阶写法,使用switch:
html:
<el-table
ref="multipleTable"
:data="orderActivityListVOS"
tooltip-effect="dark"
style="width: 100%"
@selection-change="handleSelectionChange"
>
<el-table-column
prop="useType"
:formatter="formatterUseType"
label="使用条件"
width="100"
>
</el-table-column>
</el-table>
js:
methods: {
// 使用条件(页面使用formatter调用)
formatterUseType(row) {
let text = "";
switch (row.useType) {
case 1:
text = "无限制";
break;
case 2:
text = "满减";
break;
default:
text = "—";
}
return text;
},
}
版权声明:本文为leng0920原创文章,遵循CC 4.0 BY-SA版权协议,转载请附上原文出处链接和本声明。