Browse Source

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

pull/4861/head
tangjinzhou 3 years ago
parent
commit
bbf1cc8a6f
  1. 9
      components/breadcrumb/BreadcrumbItem.tsx

9
components/breadcrumb/BreadcrumbItem.tsx

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

Loading…
Cancel
Save