问题:
解决方案
我在
el-table-column
里使用了template
标签来进行包裹,里面通过v-if
判断是否显示,但是会出现表格错乱或者不同步的问题。
<el-table-column label="名字" prop="name">
<template slot-scope="{ row }">
<div class="flexCenter" :title="row.server_filename">
<el-button v-if="row.isflag" @click="handleName"> {{row.name }}</el-button>
<el-button v-else @click="handleName"> {{ row.name }}</el-button>
</div>
</template>
</el-table-column>
解决方法:
必须要在
el-table-column
里加入:key="Math.random()"
,通过生成随机数来刷新表格
由于我在
el-table-column
里加入了:key="Math.random()"
,会导致表头部分闪烁的问题
解决方法:
element-ui
中的dolayout
函数可以很好的解决表头闪烁的问题
beforeUpdate () {
this.$nextTick(() => {
this.$refs.file_table.doLayout()
})
},