How to realize in-table Editing with vue+element

< hr >

as shown in the figure, I want to use element-ui to achieve a function of editing in such a table, please give me a train of thought, thank you!

Feb.15,2022

double-click the cell to edit
Preview: https://jsfiddle.net/bgfxv3eu/


el-table-column do not want to prop. Write
< template slot-scope= "props" >
< / template >
and then get the contents of the table through scope.row.XXX.
write a v-show of span and input on the contrary. When you click to edit, let show reverse ok.
is roughly

.
<el-table-column  label="">
    <template slot-scope="scope">
        <div class="content-rowspan">
            <div v-for="(list,index) in scope.row.lists">
                <p v-show="scope.row.show">
                    {{list}}                                                       
                    <el-button  class="delelist" type="danger" size="small"  @click="delelist(tableData1,scope.$index,index)"></el-button>
                

<el-input type="textarea" :autosize="{ minRows: 2, maxRows: 4}" v-show="!scope.row.show" v-model="scope.row.lists[index]"></el-input> </div> <div><el-button size="small" type="primary" icon="plus" @click="addlist(tableData1,scope.$index)"></el-button></div> </div> </template> </el-table-column>

the lower version is scope= "scope"


gives you an idea, and you can see if you can understand:
1. Put one in each column that needs to be clicked to be editable, which is equal to the width and height of that column. And the style is the same input input box
2, use v-if and v-else to control input and span (I imagine binding content and display as contained in span)
3, let v-model and span binding values of input are the same , and then define a variable to control the show-hidden switch of input and span. The content displayed at this time is consistent with the content bound by span, so the changes will take effect in real time without event control
5. When input loses focus or the user presses the enter key, input > hides span > shows


ideas, but I make it a component, and the parameters of v-show change according to the data model in my component. This will not cause the line you say to become an input box. The main reason is that if there are too many input boxes, it is too troublesome to configure visible parameters separately


I'll give you an ultra-simple idea. Vue has a magic component called < component > dynamic component
< component: is= "type" > < / component >

.

type = TableText or TableInput
it's up to you


my idea is about the same as upstairs. Put an input, in each cell and click show, to edit enter hide

.

but you can also try the contenteditable of ide/HTML/Content_Editable-sharp%E6%A6%82%E8%BF%B0" rel=" nofollow noreferrer "> h5

.
MySQL Query : SELECT * FROM `codeshelper`.`v9_news` WHERE status=99 AND catid='6' ORDER BY rand() LIMIT 5
MySQL Error : Disk full (/tmp/#sql-temptable-64f5-1e55f3e-45390.MAI); waiting for someone to free some space... (errno: 28 "No space left on device")
MySQL Errno : 1021
Message : Disk full (/tmp/#sql-temptable-64f5-1e55f3e-45390.MAI); waiting for someone to free some space... (errno: 28 "No space left on device")
Need Help?