mirror of
https://github.com/element-plus/element-plus.git
synced 2026-03-13 07:51:17 +08:00
fix(components): [data-picker] use renderSlot simplified code (#15036)
This commit is contained in:
@@ -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>,
|
||||
])
|
||||
}
|
||||
},
|
||||
})
|
||||
|
||||
Reference in New Issue
Block a user