element-ui中的el-table-column加v-if不生效,表头错乱

    技术2022-07-15  37

     项目中需要按照不同的媒体类型,展示不同的表头且数据字段也不同。可以增加不同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>

     

    Processed: 0.011, SQL: 9