mirror of
https://github.com/element-plus/element-plus.git
synced 2026-03-13 07:51:17 +08:00
20 lines
623 B
TypeScript
20 lines
623 B
TypeScript
import { defineComponent, h, inject } from 'vue'
|
|
import { useNamespace } from '@element-plus/hooks'
|
|
import { ROOT_TREE_INJECTION_KEY, treeNodeContentProps } from './virtual-tree'
|
|
|
|
export default defineComponent({
|
|
name: 'ElTreeNodeContent',
|
|
props: treeNodeContentProps,
|
|
setup(props) {
|
|
const tree = inject(ROOT_TREE_INJECTION_KEY)
|
|
const ns = useNamespace('tree')
|
|
return () => {
|
|
const node = props.node
|
|
const { data } = node!
|
|
return tree?.ctx.slots.default
|
|
? tree.ctx.slots.default({ node, data })
|
|
: h('span', { class: ns.be('node', 'label') }, [node?.label])
|
|
}
|
|
},
|
|
})
|