4

element el-table 表格列 v-if 显示 隐藏 乱序问题

 2 years ago
source link: https://www.geekjc.com/post/5ed3bded4a81ad7ef841518b
Go to the source link to view the article. You can view the picture content, updated content and better typesetting reading experience. If the link is broken, please click the button below to view the snapshot at that time.

element el-table 表格列 v-if 显示 隐藏 乱序问题

时间: 05/31/2020作者: ll浏览量: 1517

当tab为投保人时,表格中显示字段为投保人相关信息 当tab为被保人时,表格中显示字段为被保人相关信息 我在来回切换tab时,发现用v-if控制的字段列经常乱序。字段展示先后顺序不一。 如图所示: 2020053101.png

解决方法:在table-column中加入:key=“Math.random()” 如下所示代码

<el-table-column  
prop="apptPersonName"  
label="投保人姓名"  
v-if="category===1" :key="Math.random()">  
</el-table-column>  
<el-table-column  
prop="apptCellPhone"  
label="投保人手机号"  
v-if="category===1" :key="Math.random()">  
</el-table-column>  
<el-table-column  
prop="insuredPersonName"  
label="被保人姓名"  
v-if="category===0" :key="Math.random()">  
</el-table-column>  
<el-table-column  
prop="insuredCellPhone"  
label="被保人手机号"  
v-if="category===0" :key="Math.random()">  
</el-table-column>

About Joyk


Aggregate valuable and interesting links.
Joyk means Joy of geeK