ant-design-vue/components/vc-tree-select/src/SelectNode.jsx

35 lines
858 B
Vue
Raw Normal View History

2019-01-12 03:33:27 +00:00
import { TreeNode } from '../../vc-tree';
/**
* SelectNode wrapped the tree node.
* Let's use SelectNode instead of TreeNode
* since TreeNode is so confuse here.
*/
export default {
functional: true,
name: 'SelectNode',
isTreeNode: true,
props: TreeNode.props,
2019-01-12 03:33:27 +00:00
render(h, context) {
const { props, slots, listeners, data } = context;
const $slots = slots();
const children = $slots.default;
delete $slots.default;
const treeNodeProps = {
2019-01-12 03:33:27 +00:00
...data,
on: { ...listeners, ...data.nativeOn },
props,
};
const slotsKey = Object.keys($slots);
return (
<TreeNode {...treeNodeProps}>
{children}
{slotsKey.length
? slotsKey.map(name => {
return <template slot={name}>{$slots[name]}</template>;
})
: null}
</TreeNode>
);
},
2019-01-12 03:33:27 +00:00
};