兩種方式都可以,主要是后台傳過來數據,有的是字母比如,NY之類的,N代表好,Y代表不好,我們在頁面顯示時候要顯示文字,這個時候用
<el-table-column prop="createTime" label="創建時間" :formatter="dateFormat">
然后js
dateFormat(row, column, cellValue, index){ const daterc = row[column.property] if(daterc!=null){ const timeFormat= daterc.split("T")[0]; return timeFormat; } },
第二種方式
<el-table-column prop="isLine" label="是否在線"> <template slot-scope="scope"> <span v-if="scope.row.isLine == 'N'" style="color:red">不在線</span> <span v-else>在線</span> </template> </el-table-column>