前言:有时候我们前端展示的信息,是根据后端返回过来的字段值来动态展示的,这时候可以使用插槽。
// scope.row 代表当前循环的每一项单独的个体对象(相当于item)
<el-table-column label="类别">
<template slot-scope="scope">
<span v-if="scope.row.num==0">HTML</span>
<span v-if="scope.row.num==1">Ajax</span>
<span v-if="scope.row.num==2">CSS</span>
<span v-if="scope.row.num==3">JavaScript</span>
<span v-if="scope.row.num==4">框架</span>
<span v-if="scope.row.num==5">其他</span>
<span v-if="scope.row.num==6">小说</span>
<span v-else>{{scope.row.key}}</span>
</template>
</el-table-column>