el-table 动态添加删除 -- 鼠标移入移出显隐删除图标
<el-table class="list-box"
:data="replaceDataList" border>
<el-table-column label="原始值" prop="original" align="center" >
<template slot-scope="scope">
<div @mouseenter="showClickIcon = scope.$index" @mouseleave="showClickIcon = null">
<el-input style="width:80%" v-model="scope.row.original" placeholder="输入原值" />
</div>
</template>
</el-table-column>
<el-table-column label="替换为" prop="replace" align="center" >
<template slot-scope="scope">
<div @mouseenter="showClickIcon = scope.$index" @mouseleave="showClickIcon = null">
<div style="display:inline-block;width:80%" >
<el-input v-model="scope.row.replace" placeholder="输入替换值" />
</div>
<span v-if="showClickIcon == scope.$index" style="margin-left:10px">
<i @click="delRow(scope.$index)" class="el-icon-delete"></i>
</span>
</div>
</template>
</el-table-column>
</el-table>
<div class="addclass">
<span @click="addRow">+ 添加</span>
</div>
// 增加一行
addRow() {
const row = {
original: '',
replace: '',
};
this.replaceDataList.push(row);
},
// 删除指定行
delRow(index) {
this.replaceDataList.splice(index, 1);
},
原文地址:https://blog.csdn.net/szzlh123456789/article/details/140375684
免责声明:本站文章内容转载自网络资源,如本站内容侵犯了原著者的合法权益,可联系本站删除。更多内容请关注自学内容网(zxcms.com)!