vue elementUI el-table 表格双击可编辑
程序员文章站
2022-06-08 15:02:21
...
<template>
//表格也可以写成原生的table
<el-table :data="addPlanRoute" border style="width:100%" @cell-dblclick="tableDbEdit">
<el-table-column property="order1" label="顺序"></el-table-column>
<el-table-column property="order2" label="装车点">
<template slot-scope="scope">
<el-input v-model="scope.row.order2" placeholder="请输入内容"></el-input>
</template>
</el-table-column>
</el-table>
</template>
<script>
export default{
data(){
return{}
},
methods:{
tableDbEdit(row, column, cell, event) {
console.log(row, column, cell, event);
if (column.label != "顺序") {
event.target.innerHTML = "";
let cellInput = document.createElement("input");
cellInput.value = "";
cellInput.setAttribute("type", "text");
cellInput.style.width = "80%";
cell.appendChild(cellInput);
cellInput.onblur = function() {
cell.removeChild(cellInput);
event.target.innerHTML = cellInput.value;
};
}
}
}
}
</script>
推荐阅读
-
VUE2.0 ElementUI2.0表格el-table自适应高度的实现方法
-
VUE2.0+ElementUI2.0表格el-table循环动态列渲染的写法详解
-
VUE2.0+ElementUI2.0表格el-table实现表头扩展el-tooltip
-
vue elementUI el-table 表格双击可编辑
-
vue-elementUI-可编辑的表格
-
VUE2.0 ElementUI2.0表格el-table自适应高度的实现方法
-
VUE2.0+ElementUI2.0表格el-table循环动态列渲染的写法详解
-
VUE2.0+ElementUI2.0表格el-table实现表头扩展el-tooltip