mirror of
https://github.com/element-plus/element-plus.git
synced 2026-03-13 07:51:17 +08:00
* perf: change to import-x * feat: add rules * chore: fix rule * chore: fix * chore: fix * chore: fix * style: `pnpm lint:fix` * Revert "style: `pnpm lint:fix`" This reverts commitdb0116a288. * Revert "chore: fix" This reverts commit69c82a90c0. * chore: fix * style: `pnpm lint:fix` * fix: lint * chore: `pnpm format`
41 lines
1.2 KiB
Vue
41 lines
1.2 KiB
Vue
<script lang="ts">
|
|
import { defineComponent, h, inject, renderSlot } from 'vue'
|
|
import ElText from '@element-plus/components/text'
|
|
import { useNamespace } from '@element-plus/hooks'
|
|
import { NODE_INSTANCE_INJECTION_KEY, ROOT_TREE_INJECTION_KEY } from './tokens'
|
|
|
|
import type { ComponentInternalInstance } from 'vue'
|
|
import type { RootTreeType } from './tree.type'
|
|
|
|
export default defineComponent({
|
|
name: 'ElTreeNodeContent',
|
|
props: {
|
|
node: {
|
|
type: Object,
|
|
required: true,
|
|
},
|
|
renderContent: Function,
|
|
},
|
|
setup(props) {
|
|
const ns = useNamespace('tree')
|
|
const nodeInstance = inject<ComponentInternalInstance>(
|
|
NODE_INSTANCE_INJECTION_KEY
|
|
)
|
|
const tree = inject<RootTreeType>(ROOT_TREE_INJECTION_KEY)!
|
|
return () => {
|
|
const node = props.node
|
|
const { data, store } = node
|
|
return props.renderContent
|
|
? props.renderContent(h, { _self: nodeInstance, node, data, store })
|
|
: renderSlot(tree.ctx.slots, 'default', { node, data }, () => [
|
|
h(
|
|
ElText,
|
|
{ tag: 'span', truncated: true, class: ns.be('node', 'label') },
|
|
() => [node.label]
|
|
),
|
|
])
|
|
}
|
|
},
|
|
})
|
|
</script>
|