fix(components): [data-picker] use renderSlot simplified code (#15036)

This commit is contained in:
一只前端汪
2023-12-05 15:10:08 +08:00
committed by GitHub
parent 005bdf6143
commit 0482d11337

View File

@@ -1,4 +1,4 @@
import { defineComponent, inject } from 'vue'
import { defineComponent, inject, renderSlot } from 'vue'
import { useNamespace } from '@element-plus/hooks'
import { ROOT_PICKER_INJECTION_KEY } from '../constants'
import { basicCellProps } from '../props/basic-cell'
@@ -11,24 +11,12 @@ export default defineComponent({
const { slots } = inject(ROOT_PICKER_INJECTION_KEY)!
return () => {
const { cell } = props
if (slots.default) {
const list = slots.default(cell).filter((item) => {
return (
item.patchFlag !== -2 &&
item.type.toString() !== 'Symbol(Comment)' &&
item.type.toString() !== 'Symbol(v-cmt)'
)
})
if (list.length) {
return list
}
}
return (
return renderSlot(slots, 'default', { ...cell }, () => [
<div class={ns.b()}>
<span class={ns.e('text')}>{cell?.text}</span>
</div>
)
</div>,
])
}
},
})