当前位置:网站首页>El table implements editable table
El table implements editable table
2022-07-26 13:22:00 【Suzerk】
Realization el-table The editable table of is shown in the figure :

The following shows some code :
<el-table-column label=" Price " min-width="20" align="center">
<template slot-scope="scope">
<el-input
v-if="scope.row.edit"
v-model="scope.row.price"
placeholder=" Price "
></el-input>
<span v-else>{
{
scope.row.price }}</span>
</template>
</el-table-column>
<el-table-column label=" stock " min-width="20" align="center">
<template slot-scope="scope">
<el-input
v-if="scope.row.edit"
v-model="scope.row.store"
placeholder=" stock "
></el-input>
<span v-else>{
{
scope.row.store }}</span>
</template>
</el-table-column>
<el-table-column
label=" operation "
align="center"
width="230"
class-name="small-padding fixed-width"
>
<template slot-scope="scope">
<el-button
@click="confirmData(scope.row)"
v-if="scope.row.edit"
type="success"
size="medium"
>
<i class="el-icon-check" aria-hidden="true"></i>
</el-button>
<div v-else>
<el-button
type="primary"
size="medium"
@click="editData(scope.row)"
>
<i class="el-icon-edit" aria-hidden="true"></i>
</el-button>
<el-button
type="danger"
size="medium"
@click="handleDelete(scope)"
>
<i class="el-icon-delete" aria-hidden="true"></i>
</el-button>
</div>
</template>
</el-table-column>
methods:
editData(row) {
row.edit = true;
// console.log(row.edit);
// console.log(row.price);
},
confirmData(row) {
row.edit = false;
// console.log(row.edit);
// console.log(row.price);
this.$notify({
title: "Success",
message: " Edit success ",
type: "success",
duration: 2000,
});
handleDelete(row, index) {
this.$notify({
title: "Success",
message: "Delete Successfully",
type: "success",
duration: 2000,
});
this.list.splice(index, 1);
},
Be careful : After writing this, I found that clicking the button changed edit When the value of , Cannot react immediately in view in , And every line will affect , So we dynamically record all arrays add to edit attribute .
stay getList Method to add edit attribute .
let data = JSON.parse(JSON.stringify(this.list ? this.list : []));
data.forEach((element) => {
element["edit"] = false;
});
this.list = data;
边栏推荐
- 深度学习3D人体姿态估计国内外研究现状及痛点
- [flower carving hands-on] fun music visualization series small project (12) -- meter tube fast rhythm light
- AI-理论-知识图谱1-基础
- Flutter multi-channel packaging operation
- 12 brand management of commodity system in gulimall background management
- Use float to realize left, middle and right layout, and the middle content is adaptive
- Sword finger offer (21): push in and pop-up sequence of stack
- 父组件访问子组件的方法或参数 (子组件暴漏出方法defineExpose)
- Shutter background graying effect, how transparency, gray mask
- 概率论与数理统计
猜你喜欢

Shutter background graying effect, how transparency, gray mask

【上位机教程】CANopen通信下一体化步进电机与台达PLC(AS228T)的应用

Win11+VS2019配置YOLOX

一笔画问题(中国邮递员问题)

Oom caused by improper use of multithreading
![[applet] why can't the onreachbottom event be triggered? (one second)](/img/da/3641040c63f6db4d227dcf2ff89919.png)
[applet] why can't the onreachbottom event be triggered? (one second)

时间复杂度和空间复杂度

Kubernetes flannel: host-gw mode

1312_ Apply 7z command for compression and decompression

银行业客户体验管理现状与优化策略分析
随机推荐
panic: Error 1045: Access denied for user ‘root‘@‘117.61.242.215‘ (using password: YES)
为什么要做“密评”?
Sword finger offer (IX): abnormal jumping steps
【C语言学习者必会的题目集锦1】巩固基础,稳步提高
LeetCode 2119. 反转两次的数字
MySQL data directory (3) -- table data structure MyISAM (XXVI)
HCIP第十一天比较(BGP的配置、发布)
同花顺开的账户安全吗?
[upper computer tutorial] Application of integrated stepping motor and Delta PLC (as228t) under CANopen communication
B+ tree (5) introduction to MyISAM -- MySQL from getting started to mastering (17)
如何面对科技性失业?
Mysql数据目录(1)---数据库结构(二十四)
学习pinia 介绍-State-Getters-Actions-Plugins
MVVM architecture encapsulation of kotlin series (kotlin+mvvm)
Mysql数据目录(3)---表数据结构myISAM(二十六)
JSON数据传递参数&日期型参数传递
B+树(4)联合索引 --mysql从入门到精通(十六)
解决方案丨5G技术助力搭建智慧园区
维度灾难 维数灾难 暂记
Leetcode 217. there are duplicate elements