根据需求,在table中展示相应数据
1.使用v-if,根据不同条件展示相对应的数据
<el-table-column
header-align="center"
label="信息"
width="500"
align="top"
>
<template slot-scope="scope">
<span v-if="scope.row.bynr === null && scope.row.byys === null && scope.row.bybzyy === null">{{scope.row.brzyy}}</span>
<span v-else>{{scope.row.bynr}}+{{scope.row.byys}}+{{scope.row.bybzyy}}</span>
</template>
</el-table-column>
2. 使用:formatter="xxxx"
因为需求,要显示时间为2020-11-11,但是从数据库获得的时间都是2020-11-11 11:11:11这样子的。于是在网上看到:formatter这个东西。发现能成功解决我的问题
因为数据库存时间用的是varchar,所以取字符串前几位。
<el-table-column
header-align="center"
label="xx时间"
prop="xxTime"
width="130"
:formatter="xxTimeFormat"
align="center"
></el-table-column>
//methods里使用
xxTimeFormat(row, column){
return row.ryrq.slice(0,10);
},