1.列中引用
{
headerName: '日期',
field: 'inputDate',
maxWidth: 120,
height: 110,
cellEditor: `DateFormat`,
cellEditorPopup: true,
rowSpan: this.rowSpan,
cellStyle: {
backgroundColor: '#fff',
borderTop: '1px solid rgba(200,200,200,0.25) ',
borderBottom: '1px solid lightgrey ',
borderLeft: '1px solid lightgrey ',
borderRight: '1px solid lightgrey '
}
},
cellEditor: `DateFormat`---------------引用的组件(记得import导入进来)
cellEditorPopup: true,-------------------双击单元格是否弹出
2.定义日期组件
<template>
<div>
<el-date-picker
v-model="value1"
type="date"
format="yyyy-MM-dd"
placeholder="选择日期"
@change="blurdate"
/>
</div>
</template>
<script>
export default {
data() {
return {
value1: this.$moment(new Date()).format('YYYY-MM-DD')
}
},
methods: {
getValue() {
return this.value1 ? this.$moment(this.value1).format('YYYY-MM-DD') : null
},
blurdate() {
this.params.api.stopEditing()
}
}
}
</script>
getValue()-------------返回值给表格
this.params.api.stopEditng()--------停止表格编辑(可以在表格数据绑定之前调用)