fix: breadcrumb.item click not work, close #4845

pull/4861/head
tangjinzhou 2021-11-05 09:51:44 +08:00
parent 215a4d5752
commit bbf1cc8a6f
1 changed files with 6 additions and 3 deletions

View File

@ -20,7 +20,7 @@ export default defineComponent({
props: breadcrumbItemProps, props: breadcrumbItemProps,
emits: ['click'], emits: ['click'],
slots: ['separator', 'overlay'], slots: ['separator', 'overlay'],
setup(props, { slots }) { setup(props, { slots, emit }) {
const { prefixCls } = useConfigInject('breadcrumb', props); const { prefixCls } = useConfigInject('breadcrumb', props);
/** /**
* if overlay is have * if overlay is have
@ -41,11 +41,14 @@ export default defineComponent({
return breadcrumbItem; return breadcrumbItem;
}; };
const handleClick = (e: MouseEvent) => {
emit('click', e);
};
return () => { return () => {
const separator = getPropsSlot(slots, props, 'separator') ?? '/'; const separator = getPropsSlot(slots, props, 'separator') ?? '/';
const children = getPropsSlot(slots, props); const children = getPropsSlot(slots, props);
let link: JSX.Element; let link: JSX.Element;
if (props.href !== undefined) { if (props.href !== undefined) {
link = <a class={`${prefixCls.value}-link`}>{children}</a>; link = <a class={`${prefixCls.value}-link`}>{children}</a>;
} else { } else {
@ -55,7 +58,7 @@ export default defineComponent({
link = renderBreadcrumbNode(link, prefixCls.value); link = renderBreadcrumbNode(link, prefixCls.value);
if (children) { if (children) {
return ( return (
<span> <span onClick={handleClick}>
{link} {link}
{separator && <span class={`${prefixCls.value}-separator`}>{separator}</span>} {separator && <span class={`${prefixCls.value}-separator`}>{separator}</span>}
</span> </span>