一、
<el-table-column
prop="serial"
label="序号"
><template slot-scope="scope">
<span
@click.stop="scope.row.showInput = true"
style="display: inline-block;width: 100%;"
v-if="!scope.row.showInput"
>{{ scope.row.serial }}</span
>
<el-input
v-focus
size="small"
@change="changeSerial(scope.row)"
@blur="scope.row.showInput = false"
v-if="scope.row.showInput"
v-model="scope.row.serial"
></el-input>
</template>
</el-table-column>
二、
export default {
directives: {
focus: {
inserted: function(el) {
for(let i=0;i<el.childNodes.length;i++){
if(el.childNodes[i].nodeName=='INPUT'){
el.childNodes[i].focus()
}
}
}
}
},
data () {
return {
tabData:[{showInput:false,serial:0}]
}
},
methods:{
changeSerial(row){
console.log(roe.data)
}
}
}