<el-table @cell-dblclick="editCell">
<el-table-column :key="randomKey" prop="name">
<template slot-scope="{row,column}" >
<el-select
v-show="row[column.property + 'isShow']"
:ref="column.property"
@blur="alterData(row,column)">
<el-option>el-option>
el-select>
<span v-show="!row[column.property + 'isShow']">文本span>
template>
el-table-column>
el-table>
editCell(row, column){
row[column.property + 'isShow'] = true
this.refreshTable()
this.$nextTick(() => {
this.$refs[column.property] && this.$refs[column.property].focus()
})
},
refreshTable () {
this.randomKey = Math.random()
},
alterData (row, column) {
row[column.property + 'isShow'] = false
},
- 1
- 2
- 3
- 4
- 5
- 6
- 7
- 8
- 9
- 10
- 11
- 12
- 13
- 14
- 15
- 16
- 17
- 18