elementui可编辑单元格_ElementUI 表格可编辑单元格
頁面
export default{
components: {
EditableCell: () => import('@/components/EditableCell/EditableCell.vue'),
},
data() {
return {
tableData:[
{
date:"2020-12-01",
name:"my name is elementui",
address:"浙江省杭州市西湖區(qū)",
}
]
}
},
methods: {
onCellChange(val, row) {
// 將編輯之后的值 對應(yīng)復(fù)制給 表格數(shù)據(jù)
row.address = val;
}
}
}
組件
{{ value || ' ' }}
export default{
props: {
text: String,
},
data() {
return {
value: this.text,
editable: false,
}
},
methods: {
handleChange(e) {
const value = e.target.value;
this.value = value;
},
check() {
this.editable = false;
this.$emit('changeValue', this.value);
},
edit() {
this.editable = true;
}
}
}
.editable-cell {
position: relative;
}
.editable-cell-input-wrapper,.editable-cell-text-wrapper {
padding-right: 24px;
height: 28px;
line-height: 28px;
}
.editable-cell-text-wrapper {
/* padding: 5px 24px 5px 5px; */
}
.editable-cell-input-wrapper .editable-input{
float: left;
}
.editable-cell-icon,.editable-cell-icon-check {
position: absolute;
top:0;
bottom:0;
right: 0;
margin:auto;
cursor: pointer;
}
.editable-cell-icon {
width:16px;
height:16px;
line-height: 16px;
text-align: center;
display: none;
}
.editable-cell-icon-check {
width:16px;
height:16px;
line-height: 16px;
text-align: center;
}
.editable-cell:hover .editable-cell-icon {
display: inline-block;
}
.editable-cell-icon:hover,.editable-cell-icon-check:hover {
color: #108ee9;
}
總結(jié)
以上是生活随笔為你收集整理的elementui可编辑单元格_ElementUI 表格可编辑单元格的全部內(nèi)容,希望文章能夠幫你解決所遇到的問題。
- 上一篇: iOS16支持哪些机型iOS16新功能汇
- 下一篇: 龙之国物语如何点赞(龙是否真的存在过)