当前位置:网站首页>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;
边栏推荐
- Solution 5g technology helps build smart Parks
- 银行业客户体验管理现状与优化策略分析
- Emotion analysis model based on Bert
- Unicode file parsing methods and existing problems
- Tupu 3D visual national style design | collision between technology and culture "cool" spark“
- 时间复杂度和空间复杂度
- B+ tree (3) clustered index, secondary index -- MySQL from entry to proficiency (XV)
- Kubernetes flannel: host-gw mode
- Solution: unable to load the file c:\users\user\appdata\roaming\npm\npx PS1, because running scripts is prohibited on this system.
- Use positioning to realize left, middle and right layout, and the middle content is adaptive
猜你喜欢
![[upper computer tutorial] Application of integrated stepping motor and Delta PLC (as228t) under CANopen communication](/img/d4/c677de31f73a0e0a4b8b10b91e984a.png)
[upper computer tutorial] Application of integrated stepping motor and Delta PLC (as228t) under CANopen communication

Example of establishing socket communication with Siemens PLC based on C # open TCP communication

MVVM architecture encapsulation of kotlin series (kotlin+mvvm)

Niuke brush sql---2

AI-理论-知识图谱1-基础

Activity.onStop() 延迟10秒?精彩绝伦的排查历程

Learn about Pinia state getters actions plugins

flutter多渠道打包运行

基于C#实现的学生考试系统

【上位机教程】CANopen通信下一体化步进电机与台达PLC(AS228T)的应用
随机推荐
JSON data transfer parameters & date type parameter transfer
Leetcode 2119. number reversed twice
Example of establishing socket communication with Siemens PLC based on C # open TCP communication
Analysis on the current situation and optimization strategy of customer experience management in banking industry
LeetCode 69. x 的平方根
Streamnational team culture: a "transparent" company
Sword finger offer (x): rectangular coverage
Mysql数据目录(1)---数据库结构(二十四)
MySQL data directory (2) -- table data structure (XXV)
Some practical operations of vector
How to face scientific and technological unemployment?
解决方案丨5G技术助力搭建智慧园区
HCIP第十一天比较(BGP的配置、发布)
基于Locust框架进行文件上传下载性能测试
Use float to realize left, middle and right layout, and the middle content is adaptive
Oom caused by improper use of multithreading
Mysql数据目录(2)---表数据结构(二十五)
8 年产品经验,我总结了这些持续高效研发实践经验 · 研发篇
The difference between $route and $route
B+树挑选索引(1)---mysql从入门到精通(二十二)