当前位置:网站首页>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;
边栏推荐
- Precautions for triggering pytest.main() from other files
- [applet] why can't the onreachbottom event be triggered? (one second)
- Px2rem loader converts PX into REM and adapts to mobile vant UI and other frameworks
- [5g] what are Cu and Du in 5g?
- JSON数据传递参数&日期型参数传递
- 如何面对科技性失业?
- Sword finger offer (VII): Fibonacci sequence
- 【上位机教程】CANopen通信下一体化步进电机与台达PLC(AS228T)的应用
- B+树索引使用(7)匹配列前缀,匹配值范围(十九)
- 一笔画问题(中国邮递员问题)
猜你喜欢
![[flower carving hands-on] interesting and fun music visualization series small project (13) -- organic rod column lamp](/img/d4/7b9c7c99d46661e1be2963a342dd18.jpg)
[flower carving hands-on] interesting and fun music visualization series small project (13) -- organic rod column lamp

Elementary notes of binary tree

3D modeling and rendering based on B é zier curve

Kubernetes APIServer 限流策略

Oom caused by improper use of multithreading

同站攻击(相关域攻击)论文阅读 Can I Take Your Subdomain?Exploring Same-Site Attacks in the Modern Web

AI theory knowledge map 1 Foundation

【花雕动手做】有趣好玩的音乐可视化系列小项目(12)---米管快速节奏灯

flutter多渠道打包运行

Kubernetes apiserver current limiting strategy
随机推荐
vector的一些实用操作
Flutter textfield sets the height and automatically wraps lines, and the rounded border removes the underline
PostgreSQL official website download error
Solve the problem that the remote host cannot connect to the MySQL database
Unity中序列化类为json格式
The best engineer was "forced" away by you like this!
1312_ Apply 7z command for compression and decompression
学习pinia 介绍-State-Getters-Actions-Plugins
Target detection network r-cnn series
目标检测网络R-CNN 系列
Leetcode 2119. number reversed twice
基于BERT的情感分析模型
JSON data transfer parameters & date type parameter transfer
B+树挑选索引(1)---mysql从入门到精通(二十二)
A college archives management system based on asp.net
AI theory knowledge map 1 Foundation
Leetcode 263. ugly number
Hcip day 11 comparison (BGP configuration and release)
This article explains the FS file module and path module in nodejs in detail
12 brand management of commodity system in gulimall background management