#1275 for breadcrumb
parent
bede50d494
commit
1bdf46a22c
|
@ -10,6 +10,12 @@ const BreadcrumbProps = [
|
||||||
type: "menuitem",
|
type: "menuitem",
|
||||||
default: "null",
|
default: "null",
|
||||||
description: "Configuration for the home icon."
|
description: "Configuration for the home icon."
|
||||||
|
},
|
||||||
|
{
|
||||||
|
name: "exact",
|
||||||
|
type: "boolean",
|
||||||
|
default: "true",
|
||||||
|
description: "Whether to apply 'router-link-active-exact' class if route exactly matches the item path."
|
||||||
}
|
}
|
||||||
];
|
];
|
||||||
|
|
||||||
|
|
|
@ -1,6 +1,7 @@
|
||||||
interface BreadcrumbProps {
|
interface BreadcrumbProps {
|
||||||
home?: any;
|
home?: any;
|
||||||
model?: any[];
|
model?: any[];
|
||||||
|
exact?: boolean;
|
||||||
}
|
}
|
||||||
|
|
||||||
declare class Breadcrumb {
|
declare class Breadcrumb {
|
||||||
|
|
|
@ -1,10 +1,10 @@
|
||||||
<template>
|
<template>
|
||||||
<nav class="p-breadcrumb p-component" aria-label="Breadcrumb">
|
<nav class="p-breadcrumb p-component" aria-label="Breadcrumb">
|
||||||
<ul>
|
<ul>
|
||||||
<BreadcrumbItem v-if="home" :item="home" class="p-breadcrumb-home" :template="$slots.item"/>
|
<BreadcrumbItem v-if="home" :item="home" class="p-breadcrumb-home" :template="$slots.item" :exact="exact" />
|
||||||
<template v-for="item of model" :key="item.label" >
|
<template v-for="item of model" :key="item.label">
|
||||||
<li class="p-breadcrumb-chevron pi pi-chevron-right"></li>
|
<li class="p-breadcrumb-chevron pi pi-chevron-right"></li>
|
||||||
<BreadcrumbItem :item="item" :template="$slots.item" />
|
<BreadcrumbItem :item="item" :template="$slots.item" :exact="exact" />
|
||||||
</template>
|
</template>
|
||||||
</ul>
|
</ul>
|
||||||
</nav>
|
</nav>
|
||||||
|
@ -23,6 +23,10 @@ export default {
|
||||||
home: {
|
home: {
|
||||||
type: null,
|
type: null,
|
||||||
default: null
|
default: null
|
||||||
|
},
|
||||||
|
exact: {
|
||||||
|
type: Boolean,
|
||||||
|
default: true
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
components: {
|
components: {
|
||||||
|
|
|
@ -1,13 +1,13 @@
|
||||||
<template>
|
<template>
|
||||||
<li :class="containerClass(item)" v-if="visible()">
|
<li :class="containerClass(item)" v-if="visible()">
|
||||||
<template v-if="!template">
|
<template v-if="!template">
|
||||||
<router-link v-if="item.to" :to="item.to" custom v-slot="{navigate, href}">
|
<router-link v-if="item.to" :to="item.to" custom v-slot="{navigate, href, isActive, isExactActive}">
|
||||||
<a :href="href" class="p-menuitem-link" @click="onClick($event, navigate)">
|
<a :href="href" :class="linkClass({isActive, isExactActive})" @click="onClick($event, navigate)">
|
||||||
<span v-if="item.icon" :class="iconClass"></span>
|
<span v-if="item.icon" :class="iconClass"></span>
|
||||||
<span v-if="item.label" class="p-menuitem-text">{{item.label}}</span>
|
<span v-if="item.label" class="p-menuitem-text">{{item.label}}</span>
|
||||||
</a>
|
</a>
|
||||||
</router-link>
|
</router-link>
|
||||||
<a v-else :href="item.url||'#'" class="p-menuitem-link" @click="onClick" :target="item.target">
|
<a v-else :href="item.url||'#'" :class="linkClass()" @click="onClick" :target="item.target">
|
||||||
<span v-if="item.icon" :class="iconClass"></span>
|
<span v-if="item.icon" :class="iconClass"></span>
|
||||||
<span v-if="item.label" class="p-menuitem-text">{{item.label}}</span>
|
<span v-if="item.label" class="p-menuitem-text">{{item.label}}</span>
|
||||||
</a>
|
</a>
|
||||||
|
@ -21,7 +21,8 @@ export default {
|
||||||
name: 'BreadcrumbItem',
|
name: 'BreadcrumbItem',
|
||||||
props: {
|
props: {
|
||||||
item: null,
|
item: null,
|
||||||
template: null
|
template: null,
|
||||||
|
exact: null
|
||||||
},
|
},
|
||||||
methods: {
|
methods: {
|
||||||
onClick(event, navigate) {
|
onClick(event, navigate) {
|
||||||
|
@ -39,6 +40,12 @@ export default {
|
||||||
containerClass(item) {
|
containerClass(item) {
|
||||||
return [{'p-disabled': this.disabled(item)}, this.item.class];
|
return [{'p-disabled': this.disabled(item)}, 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() {
|
visible() {
|
||||||
return (typeof this.item.visible === 'function' ? this.item.visible() : this.item.visible !== false);
|
return (typeof this.item.visible === 'function' ? this.item.visible() : this.item.visible !== false);
|
||||||
},
|
},
|
||||||
|
|
|
@ -43,6 +43,18 @@ export default {
|
||||||
</template>
|
</template>
|
||||||
</Breadcrumb>
|
</Breadcrumb>
|
||||||
</template>
|
</template>
|
||||||
|
</code></pre>
|
||||||
|
|
||||||
|
<p><i>router-link</i> with route configuration can also be used within templating for further customization.</p>
|
||||||
|
<pre v-code><code><template v-pre>
|
||||||
|
<Breadcrumb :home="home" :model="items">
|
||||||
|
<template #item="{item}">
|
||||||
|
<router-link :to="item.to" custom v-slot="{href, route, navigate, isActive, isExactActive}">
|
||||||
|
<a :href="href" @click="navigate" :class="{'active-link': isActive, 'active-link-exact": isExactActive}>{{route.fullPath}}</a>
|
||||||
|
</router-link>
|
||||||
|
</template>
|
||||||
|
</Breadcrumb>
|
||||||
|
</template>
|
||||||
</code></pre>
|
</code></pre>
|
||||||
|
|
||||||
<h5>Properties</h5>
|
<h5>Properties</h5>
|
||||||
|
@ -69,6 +81,12 @@ export default {
|
||||||
<td>menuitem</td>
|
<td>menuitem</td>
|
||||||
<td>null</td>
|
<td>null</td>
|
||||||
<td>Configuration for the home icon.</td>
|
<td>Configuration for the home icon.</td>
|
||||||
|
</tr>
|
||||||
|
<tr>
|
||||||
|
<td>exact</td>
|
||||||
|
<td>boolean</td>
|
||||||
|
<td>true</td>
|
||||||
|
<td>Whether to apply 'router-link-active-exact' class if route exactly matches the item path.</td>
|
||||||
</tr>
|
</tr>
|
||||||
</tbody>
|
</tbody>
|
||||||
</table>
|
</table>
|
||||||
|
|
|
@ -152,7 +152,7 @@ toggle(event) {
|
||||||
<td>true</td>
|
<td>true</td>
|
||||||
<td>Whether to automatically manage layering.</td>
|
<td>Whether to automatically manage layering.</td>
|
||||||
</tr>
|
</tr>
|
||||||
<tr>
|
<tr>
|
||||||
<td>exact</td>
|
<td>exact</td>
|
||||||
<td>boolean</td>
|
<td>boolean</td>
|
||||||
<td>true</td>
|
<td>true</td>
|
||||||
|
|
Loading…
Reference in New Issue