primevue-mirror/apps/showcase/doc/breadcrumb/RouterDoc.vue

123 lines
4.3 KiB
Vue
Raw Permalink Normal View History

2023-08-30 13:33:42 +00:00
<template>
<DocSectionText v-bind="$attrs">
2023-11-04 09:58:30 +00:00
<p>Items with navigation are defined with templating to be able to use a router link component, an external link or programmatic navigation.</p>
2023-08-30 13:33:42 +00:00
</DocSectionText>
2024-05-20 12:14:38 +00:00
<div class="card flex justify-center">
2023-08-30 13:33:42 +00:00
<Breadcrumb :home="home" :model="items">
2023-11-04 09:58:30 +00:00
<template #item="{ item, props }">
<router-link v-if="item.route" v-slot="{ href, navigate }" :to="item.route" custom>
<a :href="href" v-bind="props.action" @click="navigate">
<span :class="[item.icon, 'text-color']" />
<span class="text-primary font-semibold">{{ item.label }}</span>
2023-08-30 13:33:42 +00:00
</a>
</router-link>
<a v-else :href="item.url" :target="item.target" v-bind="props.action">
2024-05-20 12:14:38 +00:00
<span class="text-surface-700 dark:text-surface-0">{{ item.label }}</span>
2023-08-30 13:33:42 +00:00
</a>
</template>
</Breadcrumb>
</div>
2024-01-30 08:16:35 +00:00
<DocSectionCode :code="code" hideStackBlitz />
2023-08-30 13:33:42 +00:00
</template>
<script>
export default {
data() {
return {
home: {
icon: 'pi pi-home',
2023-12-26 18:38:03 +00:00
route: '/introduction'
2023-08-30 13:33:42 +00:00
},
2023-11-04 09:58:30 +00:00
items: [{ label: 'Components' }, { label: 'Form' }, { label: 'InputText', route: '/inputtext' }],
2023-08-30 13:33:42 +00:00
code: {
2023-09-22 12:54:14 +00:00
basic: `
<Breadcrumb :home="home" :model="items">
2023-11-04 09:58:30 +00:00
<template #item="{ item, props }">
<router-link v-if="item.route" v-slot="{ href, navigate }" :to="item.route" custom>
<a :href="href" v-bind="props.action" @click="navigate">
<span :class="[item.icon, 'text-color']" />
<span class="text-primary font-semibold">{{ item.label }}</span>
2023-08-30 13:33:42 +00:00
</a>
</router-link>
<a v-else :href="item.url" :target="item.target" v-bind="props.action">
2024-05-20 12:14:38 +00:00
<span class="text-surface-700 dark:text-surface-0">{{ item.label }}</span>
2023-08-30 13:33:42 +00:00
</a>
</template>
2023-10-15 09:38:39 +00:00
</Breadcrumb>
`,
2023-09-22 12:54:14 +00:00
options: `
<template>
2024-05-20 12:14:38 +00:00
<div class="card flex justify-center">
2023-08-30 13:33:42 +00:00
<Breadcrumb :home="home" :model="items">
2023-11-04 09:58:30 +00:00
<template #item="{ item, props }">
<router-link v-if="item.route" v-slot="{ href, navigate }" :to="item.route" custom>
<a :href="href" v-bind="props.action" @click="navigate">
<span :class="[item.icon, 'text-color']" />
<span class="text-primary font-semibold">{{ item.label }}</span>
2023-08-30 13:33:42 +00:00
</a>
</router-link>
<a v-else :href="item.url" :target="item.target" v-bind="props.action">
2024-05-20 12:14:38 +00:00
<span class="text-surface-700 dark:text-surface-0">{{ item.label }}</span>
2023-08-30 13:33:42 +00:00
</a>
</template>
</Breadcrumb>
</div>
</template>
<script>
export default {
data() {
return {
home: {
icon: 'pi pi-home',
2023-12-26 18:38:03 +00:00
route: '/introduction'
2023-08-30 13:33:42 +00:00
},
items: [
2024-01-30 08:16:35 +00:00
{ label: 'Components' },
{ label: 'Form' },
2023-11-04 09:58:30 +00:00
{ label: 'InputText', route: '/inputtext' }
2023-08-30 13:33:42 +00:00
]
}
}
}
2023-10-15 09:38:39 +00:00
<\/script>
`,
2023-09-22 12:54:14 +00:00
composition: `
<template>
2024-05-20 12:14:38 +00:00
<div class="card flex justify-center">
2023-08-30 13:33:42 +00:00
<Breadcrumb :home="home" :model="items">
2023-11-04 09:58:30 +00:00
<template #item="{ item, props }">
<router-link v-if="item.route" v-slot="{ href, navigate }" :to="item.route" custom>
<a :href="href" v-bind="props.action" @click="navigate">
<span :class="[item.icon, 'text-color']" />
<span class="text-primary font-semibold">{{ item.label }}</span>
2023-08-30 13:33:42 +00:00
</a>
</router-link>
<a v-else :href="item.url" :target="item.target" v-bind="props.action">
2024-05-20 12:14:38 +00:00
<span class="text-surface-700 dark:text-surface-0">{{ item.label }}</span>
2023-08-30 13:33:42 +00:00
</a>
</template>
</Breadcrumb>
</div>
</template>
<script setup>
import { ref } from "vue";
const home = ref({
icon: 'pi pi-home',
2023-12-26 18:38:03 +00:00
route: '/introduction'
2023-08-30 13:33:42 +00:00
});
const items = ref([
2024-01-30 08:16:35 +00:00
{ label: 'Components' },
{ label: 'Form' },
2023-11-04 09:58:30 +00:00
{ label: 'InputText', route: '/inputtext' }
2023-08-30 13:33:42 +00:00
]);
2023-10-15 09:38:39 +00:00
<\/script>
`
2023-08-30 13:33:42 +00:00
}
};
}
};
</script>