mirror of
https://github.com/primefaces/primevue.git
synced 2025-05-09 00:42:36 +00:00
Refactor #3965 - For Breadcrumb
This commit is contained in:
parent
07c234c0ed
commit
b1d229f2c8
4 changed files with 115 additions and 77 deletions
|
@ -1,17 +1,17 @@
|
|||
<template>
|
||||
<li v-if="visible()" :class="containerClass()" v-bind="ptm('menuitem')">
|
||||
<li v-if="visible()" :class="[getCXOptions('menuitem'), item.class]" v-bind="ptm('menuitem')">
|
||||
<template v-if="!templates || !templates.item">
|
||||
<router-link v-if="item.to" v-slot="{ navigate, href, isActive, isExactActive }" :to="item.to" custom>
|
||||
<a :href="href" :class="linkClass({ isActive, isExactActive })" :aria-current="isCurrentUrl()" @click="onClick($event, navigate)" v-bind="ptm('action')">
|
||||
<component v-if="templates.itemicon" :is="templates.itemicon" :item="item" class="p-menuitem-icon" />
|
||||
<span v-else-if="item.icon" :class="['p-menuitem-icon', item.icon]" v-bind="ptm('icon')" />
|
||||
<span v-if="item.label" class="p-menuitem-text" v-bind="ptm('label')">{{ label() }}</span>
|
||||
<a :href="href" :class="getCXOptions('action', { isActive, isExactActive })" :aria-current="isCurrentUrl()" @click="onClick($event, navigate)" v-bind="ptm('action')">
|
||||
<component v-if="templates.itemicon" :is="templates.itemicon" :item="item" :class="getCXOptions('icon')" />
|
||||
<span v-else-if="item.icon" :class="[getCXOptions('icon'), item.icon]" v-bind="ptm('icon')" />
|
||||
<span v-if="item.label" :class="getCXOptions('label')" v-bind="ptm('label')">{{ label() }}</span>
|
||||
</a>
|
||||
</router-link>
|
||||
<a v-else :href="item.url || '#'" :class="linkClass()" :target="item.target" :aria-current="isCurrentUrl()" @click="onClick" v-bind="ptm('action')">
|
||||
<component v-if="templates && templates.itemicon" :is="templates.itemicon" :item="item" class="p-menuitem-icon" />
|
||||
<span v-else-if="item.icon" :class="['p-menuitem-icon', item.icon]" v-bind="ptm('icon')" />
|
||||
<span v-if="item.label" class="p-menuitem-text" v-bind="ptm('label')">{{ label() }}</span>
|
||||
<a v-else :href="item.url || '#'" :class="getCXOptions('action')" :target="item.target" :aria-current="isCurrentUrl()" @click="onClick" v-bind="ptm('action')">
|
||||
<component v-if="templates && templates.itemicon" :is="templates.itemicon" :item="item" :class="getCXOptions('icon')" />
|
||||
<span v-else-if="item.icon" :class="[getCXOptions('icon'), item.icon]" v-bind="ptm('icon')" />
|
||||
<span v-if="item.label" :class="getCXOptions('label')" v-bind="ptm('label')">{{ label() }}</span>
|
||||
</a>
|
||||
</template>
|
||||
<component v-else :is="templates.item" :item="item"></component>
|
||||
|
@ -19,11 +19,11 @@
|
|||
</template>
|
||||
|
||||
<script>
|
||||
import BaseComponent from 'primevue/basecomponent';
|
||||
import BaseBreadcrumb from './BaseBreadcrumb.vue';
|
||||
|
||||
export default {
|
||||
name: 'BreadcrumbItem',
|
||||
extends: BaseComponent,
|
||||
extends: BaseBreadcrumb,
|
||||
props: {
|
||||
item: null,
|
||||
templates: null,
|
||||
|
@ -31,6 +31,12 @@ export default {
|
|||
index: null
|
||||
},
|
||||
methods: {
|
||||
getCXOptions(key, params) {
|
||||
return this.cx(key, {
|
||||
...params,
|
||||
context: this
|
||||
});
|
||||
},
|
||||
onClick(event, navigate) {
|
||||
if (this.item.command) {
|
||||
this.item.command({
|
||||
|
@ -43,18 +49,6 @@ export default {
|
|||
navigate(event);
|
||||
}
|
||||
},
|
||||
containerClass() {
|
||||
return ['p-menuitem', { 'p-disabled': this.disabled() }, this.item.class];
|
||||
},
|
||||
linkClass(routerProps) {
|
||||
return [
|
||||
'p-menuitem-link',
|
||||
{
|
||||
'router-link-active': routerProps && routerProps.isActive,
|
||||
'router-link-active-exact': this.exact && routerProps && routerProps.isExactActive
|
||||
}
|
||||
];
|
||||
},
|
||||
visible() {
|
||||
return typeof this.item.visible === 'function' ? this.item.visible() : this.item.visible !== false;
|
||||
},
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue