(vue)IView表格中点击当前行按钮图标切换其它行图标不变
效果:
html:
<Table
ref="selection"
:columns="columns"
:data="tableData"
@on-selection-change="handleSelectChange"
>
<template slot-scope="{ row, index }" slot="operation">
<span
type="text"
size="small"
v-if="play && activeIndex == index" //重点
@click="saveRow(row, index)"
>保存</span
>
<span type="text" size="small" v-else @click="editRow(row, index)"
>编辑</span
>
<span type="text" size="small" @click="deleteRow(row)">删除</span>
</template>
</Table>
js:
data(){
play: false, //判断依据来显示或者隐藏
activeIndex: 0, //索引值,把当前行的index值等于activeIndex可以知道操作的是哪一行的数据
}
methods:{
//编辑
editRow(row, index) {
this.activeIndex = index;
this.play = true;
},
//保存
saveRow(row, index) {
this.play = false;
},
}
解决参考:https://blog.csdn.net/Geezer_007/article/details/108796248