2023-08-30 14:38:19 +00:00
|
|
|
<template>
|
|
|
|
<DocSectionText v-bind="$attrs">
|
|
|
|
<p>
|
|
|
|
Since v3.33.0 the vue-router dependency of menu components is deprecated and templating should be used to define router links instead. This approach provides flexibility to be able to use any kind of router link component such as
|
2023-08-31 14:02:09 +00:00
|
|
|
<i>NuxtLink</i> or <i>router-link</i>. Here is an example with vue-router.
|
2023-08-30 14:38:19 +00:00
|
|
|
</p>
|
|
|
|
</DocSectionText>
|
2023-09-01 11:02:08 +00:00
|
|
|
<!-- <div class="card">
|
2023-08-31 14:02:09 +00:00
|
|
|
<Steps
|
|
|
|
:model="items"
|
|
|
|
aria-label="Form Steps"
|
|
|
|
:readonly="false"
|
|
|
|
:pt="{
|
|
|
|
menuitem: ({ context }) => ({
|
|
|
|
class: isActive(context.item) && 'p-highlight p-steps-current'
|
|
|
|
})
|
|
|
|
}"
|
|
|
|
>
|
|
|
|
<template #item="{ label, item, index, props }">
|
|
|
|
<router-link v-if="item.route" v-slot="routerProps" :to="item.route" custom>
|
|
|
|
<a :href="routerProps.href" v-bind="props.action" @click="($event) => routerProps.navigate($event)" @keydown.enter="($event) => routerProps.navigate($event)">
|
|
|
|
<span v-bind="props.step">{{ index + 1 }}</span>
|
|
|
|
<span v-bind="props.label">{{ label }}</span>
|
|
|
|
</a>
|
|
|
|
</router-link>
|
|
|
|
<a v-else :href="item.url" :target="item.target" v-bind="props.action">
|
|
|
|
<span v-bind="props.step">{{ index + 1 }}</span>
|
|
|
|
<span v-bind="props.label">{{ label }}</span>
|
|
|
|
</a>
|
|
|
|
</template>
|
|
|
|
</Steps>
|
2023-09-01 11:02:08 +00:00
|
|
|
</div> -->
|
2023-08-31 14:02:09 +00:00
|
|
|
<DocSectionCode :code="code" />
|
2023-08-30 14:38:19 +00:00
|
|
|
</template>
|
2023-08-31 14:02:09 +00:00
|
|
|
|
|
|
|
<script>
|
|
|
|
export default {
|
|
|
|
data() {
|
|
|
|
return {
|
2023-09-18 11:23:57 +00:00
|
|
|
// items: [
|
|
|
|
// {
|
|
|
|
// label: 'Personal',
|
|
|
|
// route: '/steps/'
|
|
|
|
// },
|
|
|
|
// {
|
|
|
|
// label: 'Seat',
|
|
|
|
// route: '/steps/seat'
|
|
|
|
// },
|
|
|
|
// {
|
|
|
|
// label: 'Payment',
|
|
|
|
// route: '/steps/payment'
|
|
|
|
// },
|
|
|
|
// {
|
|
|
|
// label: 'Confirmation',
|
|
|
|
// route: '/steps/confirmation'
|
|
|
|
// },
|
|
|
|
// {
|
|
|
|
// label: 'File Upload',
|
|
|
|
// url: '/fileupload'
|
|
|
|
// }
|
|
|
|
// ],
|
2023-08-31 14:02:09 +00:00
|
|
|
code: {
|
2023-09-22 12:54:14 +00:00
|
|
|
basic: `
|
|
|
|
<Steps :model="items" aria-label="Form Steps" :readonly="false"
|
2023-08-31 14:02:09 +00:00
|
|
|
:pt="{
|
|
|
|
menuitem: ({ context }) => ({
|
|
|
|
class: isActive(context.item) && 'p-highlight p-steps-current'
|
|
|
|
})
|
|
|
|
}">
|
|
|
|
<template #item="{ label, item, index, props }">
|
|
|
|
<router-link v-if="item.route" v-slot="routerProps" :to="item.route" custom>
|
|
|
|
<a :href="routerProps.href" v-bind="props.action" @click="($event) => routerProps.navigate($event)" @keydown.enter="($event) => routerProps.navigate($event)">
|
|
|
|
<span v-bind="props.step">{{ index + 1 }}</span>
|
|
|
|
<span v-bind="props.label">{{ label }}</span>
|
|
|
|
</a>
|
|
|
|
</router-link>
|
|
|
|
<a v-else :href="item.url" :target="item.target" v-bind="props.action">
|
|
|
|
<span v-bind="props.step">{{ index + 1 }}</span>
|
|
|
|
<span v-bind="props.label">{{ label }}</span>
|
|
|
|
</a>
|
|
|
|
</template>
|
2023-10-15 09:38:39 +00:00
|
|
|
</Steps>
|
|
|
|
`,
|
2023-09-22 12:54:14 +00:00
|
|
|
options: `
|
|
|
|
<template>
|
2023-08-31 14:02:09 +00:00
|
|
|
<div>
|
|
|
|
<div class="card">
|
|
|
|
<Steps :model="items" aria-label="Form Steps" :readonly="false"
|
|
|
|
:pt="{
|
|
|
|
menuitem: ({ context }) => ({
|
|
|
|
class: isActive(context.item) && 'p-highlight p-steps-current'
|
|
|
|
})
|
|
|
|
}">
|
|
|
|
<template #item="{ label, item, index, props }">
|
|
|
|
<router-link v-if="item.route" v-slot="routerProps" :to="item.route" custom>
|
|
|
|
<a :href="routerProps.href" v-bind="props.action" @click="($event) => routerProps.navigate($event)" @keydown.enter="($event) => routerProps.navigate($event)">
|
|
|
|
<span v-bind="props.step">{{ index + 1 }}</span>
|
|
|
|
<span v-bind="props.label">{{ label }}</span>
|
|
|
|
</a>
|
|
|
|
</router-link>
|
|
|
|
<a v-else :href="item.url" :target="item.target" v-bind="props.action">
|
|
|
|
<span v-bind="props.step">{{ index + 1 }}</span>
|
|
|
|
<span v-bind="props.label">{{ label }}</span>
|
|
|
|
</a>
|
|
|
|
</template>
|
|
|
|
</Steps>
|
|
|
|
</div>
|
|
|
|
</div>
|
|
|
|
</template>
|
|
|
|
|
|
|
|
<script>
|
|
|
|
export default {
|
|
|
|
data() {
|
|
|
|
return {
|
|
|
|
items: [
|
|
|
|
{
|
|
|
|
label: 'Personal',
|
2023-09-18 11:23:57 +00:00
|
|
|
route: '/'
|
2023-08-31 14:02:09 +00:00
|
|
|
},
|
|
|
|
{
|
|
|
|
label: 'Seat',
|
2023-09-18 11:23:57 +00:00
|
|
|
route: '/seat'
|
2023-08-31 14:02:09 +00:00
|
|
|
},
|
|
|
|
{
|
|
|
|
label: 'Payment',
|
2023-09-18 11:23:57 +00:00
|
|
|
route: '/payment'
|
2023-08-31 14:02:09 +00:00
|
|
|
},
|
|
|
|
{
|
|
|
|
label: 'Confirmation',
|
2023-09-18 11:23:57 +00:00
|
|
|
route: '/confirmation'
|
2023-08-31 14:02:09 +00:00
|
|
|
},
|
|
|
|
{
|
|
|
|
label: 'File Upload',
|
|
|
|
url: '/fileupload'
|
|
|
|
}
|
|
|
|
]
|
|
|
|
}
|
|
|
|
},
|
|
|
|
methods: {
|
|
|
|
isActive(item) {
|
|
|
|
return item.route ? this.$router.resolve(item.route).path === this.$route.path : false;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
2023-10-15 09:38:39 +00:00
|
|
|
<\/script>
|
|
|
|
`,
|
2023-09-22 12:54:14 +00:00
|
|
|
composition: `
|
|
|
|
<template>
|
2023-08-31 14:02:09 +00:00
|
|
|
<div>
|
|
|
|
<div class="card">
|
|
|
|
<Steps :model="items" aria-label="Form Steps" :readonly="false"
|
|
|
|
:pt="{
|
|
|
|
menuitem: ({ context }) => ({
|
|
|
|
class: isActive(context.item) && 'p-highlight p-steps-current'
|
|
|
|
})
|
|
|
|
}">
|
|
|
|
<template #item="{ label, item, index, props }">
|
|
|
|
<router-link v-if="item.route" v-slot="routerProps" :to="item.route" custom>
|
|
|
|
<a :href="routerProps.href" v-bind="props.action" @click="($event) => routerProps.navigate($event)" @keydown.enter="($event) => routerProps.navigate($event)">
|
|
|
|
<span v-bind="props.step">{{ index + 1 }}</span>
|
|
|
|
<span v-bind="props.label">{{ label }}</span>
|
|
|
|
</a>
|
|
|
|
</router-link>
|
|
|
|
<a v-else :href="item.url" :target="item.target" v-bind="props.action">
|
|
|
|
<span v-bind="props.step">{{ index + 1 }}</span>
|
|
|
|
<span v-bind="props.label">{{ label }}</span>
|
|
|
|
</a>
|
|
|
|
</template>
|
|
|
|
</Steps>
|
|
|
|
</div>
|
|
|
|
</div>
|
|
|
|
</template>
|
|
|
|
|
|
|
|
<script setup>
|
|
|
|
import { ref } from "vue";
|
|
|
|
import { useRouter, useRoute } from "vue-router";
|
|
|
|
|
|
|
|
const router = useRouter();
|
|
|
|
const route = useRoute();
|
|
|
|
|
|
|
|
const items = ref([
|
|
|
|
{
|
|
|
|
label: 'Personal',
|
|
|
|
route: "/"
|
|
|
|
},
|
|
|
|
{
|
|
|
|
label: 'Seat',
|
|
|
|
route: "/seat",
|
|
|
|
},
|
|
|
|
{
|
|
|
|
label: 'Payment',
|
|
|
|
route: "/payment",
|
|
|
|
},
|
|
|
|
{
|
|
|
|
label: 'Confirmation',
|
|
|
|
route: "/confirmation",
|
|
|
|
},
|
|
|
|
{
|
|
|
|
label: 'File Upload',
|
|
|
|
url: '/fileupload'
|
|
|
|
}
|
|
|
|
]);
|
|
|
|
|
|
|
|
const isActive = (item) => {
|
|
|
|
return item.route ? router.resolve(item.route).path === route.path : false;
|
|
|
|
}
|
2023-10-15 09:38:39 +00:00
|
|
|
<\/script>
|
|
|
|
`
|
2023-08-31 14:02:09 +00:00
|
|
|
}
|
|
|
|
};
|
|
|
|
},
|
|
|
|
methods: {
|
|
|
|
isActive(item) {
|
|
|
|
return item.route ? this.$router.resolve(item.route).path === this.$route.path : false;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
};
|
|
|
|
</script>
|