項目中需要按照不同的媒體類型,展示不同的表頭且數據字段也不同。可以增加不同key值解決v-if不生效問題。
<el-table-column prop="author"
align="center"
:key="Math.random()"
v-if="pathIndex == '微博' || pathIndex == '微信'"
sortable="custom"
label="帳號名稱">
</el-table-column>
<el-table-column prop="sitename"
align="center"
:key="Math.random()"
min-width="112"
v-if="pathIndex == '網絡新聞'|| pathIndex == '頭條'|| pathIndex == '電子報'"
sortable="custom"
label="媒體名稱">
<template slot-scope="scope">
<p class="G_table_hidden_ellipsis"
:title="scope.row.sitename">{{scope.row.sitename}}</p>
</template>
</el-table-column>