mirror of
https://gitee.com/ant-design-vue/ant-design-vue.git
synced 2024-12-05 05:29:01 +08:00
4ab7a681a7
* fix: update alert code * chore: declare link type * chore: declare auto-complete type * chore: declare Badge type * chore: declare Breadcrumb type * chore: declare Calendar type * chore: declare Card type * chore: declare Checkbox type * chore: declare Descriptions type * chore: declare Dropdown * chore: declare Form type * chore: declare Mentions type * chore: declare Menu type * chore: declare popconfirm type * chore: update Radio typescript * chore: declare Rate type * chore: declare Transfer type * fix: update Transfer type * fix: update type * fix: update type
69 lines
2.0 KiB
Vue
69 lines
2.0 KiB
Vue
import { defineComponent, HTMLAttributes, inject } from 'vue';
|
|
import PropTypes from '../_util/vue-types';
|
|
import { hasProp, getComponent, getSlot } from '../_util/props-util';
|
|
import { defaultConfigProvider } from '../config-provider';
|
|
import DropDown from '../dropdown/dropdown';
|
|
import DownOutlined from '@ant-design/icons-vue/DownOutlined';
|
|
|
|
export default defineComponent({
|
|
name: 'ABreadcrumbItem',
|
|
__ANT_BREADCRUMB_ITEM: true,
|
|
props: {
|
|
prefixCls: PropTypes.string,
|
|
href: PropTypes.string,
|
|
separator: PropTypes.VNodeChild.def('/'),
|
|
overlay: PropTypes.VNodeChild,
|
|
},
|
|
setup() {
|
|
return {
|
|
configProvider: inject('configProvider', defaultConfigProvider),
|
|
};
|
|
},
|
|
methods: {
|
|
/**
|
|
* if overlay is have
|
|
* Wrap a DropDown
|
|
*/
|
|
renderBreadcrumbNode(breadcrumbItem: HTMLAttributes, prefixCls: string) {
|
|
const overlay = getComponent(this, 'overlay');
|
|
if (overlay) {
|
|
return (
|
|
<DropDown overlay={overlay} placement="bottomCenter">
|
|
<span class={`${prefixCls}-overlay-link`}>
|
|
{breadcrumbItem}
|
|
<DownOutlined />
|
|
</span>
|
|
</DropDown>
|
|
);
|
|
}
|
|
return breadcrumbItem;
|
|
},
|
|
},
|
|
render() {
|
|
const { prefixCls: customizePrefixCls } = this;
|
|
const getPrefixCls = this.configProvider.getPrefixCls;
|
|
const prefixCls = getPrefixCls('breadcrumb', customizePrefixCls);
|
|
const separator = getComponent(this, 'separator');
|
|
const children = getSlot(this);
|
|
let link: HTMLAttributes;
|
|
if (hasProp(this, 'href')) {
|
|
link = <a class={`${prefixCls}-link`}>{children}</a>;
|
|
} else {
|
|
link = <span class={`${prefixCls}-link`}>{children}</span>;
|
|
}
|
|
// wrap to dropDown
|
|
link = this.renderBreadcrumbNode(link, prefixCls);
|
|
if (children) {
|
|
return (
|
|
<span>
|
|
{link}
|
|
{separator && separator !== '' && (
|
|
<span class={`${prefixCls}-separator`}>{separator}</span>
|
|
)}
|
|
</span>
|
|
);
|
|
}
|
|
return null;
|
|
},
|
|
});
|