今天在做项目中遇到了如上图这样一个问题,项目是Vue+element-ui。原因是table中用了多个v-if,解决方案有两个:
1、用v-show代替v-if(个人推荐用第二种);
2、在v-if条件语句中加key作为区分就不会报错了。
<el-table
:data="WarehousingDetails.productSkuVOList"
:header-cell-style="getRowClassDialog"
style="width: 100%">
<el-table-column
v-if="column == '' && column2 == ''"
key='name'
prop="goodsNames"
label="名称">
</el-table-column>
<el-table-column
v-if="column != ''"
:label="column">
<template slot-scope="scope">
<span>{{ scope.row.sku1Value }}</span>
</template>
</el-table-column>
<el-table-column
prop="sku2Value"
v-if="column2 != ''"
:label="column2">
</el-table-column>
<el-table-column
prop="quantity"
label="库存数量">
</el-table-column>
</el-table>