2022-09-06 12:03:37 +00:00
|
|
|
<template>
|
2022-09-14 11:26:01 +00:00
|
|
|
<li v-if="visible()" :class="containerClass(item)">
|
2022-09-06 12:03:37 +00:00
|
|
|
<template v-if="!template">
|
2022-09-14 11:26:01 +00:00
|
|
|
<router-link v-if="item.to" v-slot="{ navigate, href, isActive, isExactActive }" :to="item.to" custom>
|
|
|
|
<a :href="href" :class="linkClass({ isActive, isExactActive })" @click="onClick($event, navigate)">
|
2022-09-06 12:03:37 +00:00
|
|
|
<span v-if="item.icon" :class="iconClass"></span>
|
2022-09-14 11:26:01 +00:00
|
|
|
<span v-if="item.label" class="p-menuitem-text">{{ label() }}</span>
|
2022-09-06 12:03:37 +00:00
|
|
|
</a>
|
|
|
|
</router-link>
|
2022-09-14 11:26:01 +00:00
|
|
|
<a v-else :href="item.url || '#'" :class="linkClass()" @click="onClick" :target="item.target">
|
2022-09-06 12:03:37 +00:00
|
|
|
<span v-if="item.icon" :class="iconClass"></span>
|
2022-09-14 11:26:01 +00:00
|
|
|
<span v-if="item.label" class="p-menuitem-text">{{ label() }}</span>
|
2022-09-06 12:03:37 +00:00
|
|
|
</a>
|
|
|
|
</template>
|
|
|
|
<component v-else :is="template" :item="item"></component>
|
|
|
|
</li>
|
|
|
|
</template>
|
|
|
|
|
|
|
|
<script>
|
|
|
|
export default {
|
|
|
|
name: 'BreadcrumbItem',
|
|
|
|
props: {
|
|
|
|
item: null,
|
|
|
|
template: null,
|
|
|
|
exact: null
|
|
|
|
},
|
|
|
|
methods: {
|
|
|
|
onClick(event, navigate) {
|
|
|
|
if (this.item.command) {
|
|
|
|
this.item.command({
|
|
|
|
originalEvent: event,
|
|
|
|
item: this.item
|
|
|
|
});
|
|
|
|
}
|
|
|
|
|
|
|
|
if (this.item.to && navigate) {
|
|
|
|
navigate(event);
|
|
|
|
}
|
|
|
|
},
|
|
|
|
containerClass(item) {
|
2022-09-14 11:26:01 +00:00
|
|
|
return [{ 'p-disabled': this.disabled(item) }, this.item.class];
|
2022-09-06 12:03:37 +00:00
|
|
|
},
|
|
|
|
linkClass(routerProps) {
|
2022-09-14 11:26:01 +00:00
|
|
|
return [
|
|
|
|
'p-menuitem-link',
|
|
|
|
{
|
|
|
|
'router-link-active': routerProps && routerProps.isActive,
|
|
|
|
'router-link-active-exact': this.exact && routerProps && routerProps.isExactActive
|
|
|
|
}
|
|
|
|
];
|
2022-09-06 12:03:37 +00:00
|
|
|
},
|
|
|
|
visible() {
|
2022-09-14 11:26:01 +00:00
|
|
|
return typeof this.item.visible === 'function' ? this.item.visible() : this.item.visible !== false;
|
2022-09-06 12:03:37 +00:00
|
|
|
},
|
|
|
|
disabled(item) {
|
2022-09-14 11:26:01 +00:00
|
|
|
return typeof item.disabled === 'function' ? item.disabled() : item.disabled;
|
2022-09-06 12:03:37 +00:00
|
|
|
},
|
|
|
|
label() {
|
2022-09-14 11:26:01 +00:00
|
|
|
return typeof this.item.label === 'function' ? this.item.label() : this.item.label;
|
2022-09-06 12:03:37 +00:00
|
|
|
}
|
|
|
|
},
|
|
|
|
computed: {
|
|
|
|
iconClass() {
|
|
|
|
return ['p-menuitem-icon', this.item.icon];
|
|
|
|
}
|
|
|
|
}
|
2022-09-14 11:26:01 +00:00
|
|
|
};
|
2022-09-06 12:03:37 +00:00
|
|
|
</script>
|