mirror of
https://github.com/primefaces/primevue.git
synced 2025-05-09 17:02:38 +00:00
Steps router docs fixed
This commit is contained in:
parent
f67812b61c
commit
71fe5e55d0
3 changed files with 297 additions and 13 deletions
|
@ -3,7 +3,16 @@
|
|||
<p>Steps requires a collection of menuitems as its <i>model</i>.</p>
|
||||
</DocSectionText>
|
||||
<div class="card">
|
||||
<Steps :model="items" aria-label="Form Steps" :readonly="false">
|
||||
<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)">
|
||||
|
@ -11,10 +20,6 @@
|
|||
<span v-bind="props.label">{{ label }}</span>
|
||||
</a>
|
||||
</router-link>
|
||||
<span v-else v-bind="props.action">
|
||||
<span v-bind="props.step">{{ index + 1 }}</span>
|
||||
<span v-bind="props.label">{{ label }}</span>
|
||||
</span>
|
||||
</template>
|
||||
</Steps>
|
||||
</div>
|
||||
|
@ -44,7 +49,12 @@ export default {
|
|||
}
|
||||
],
|
||||
code: {
|
||||
basic: `<Steps :model="items" aria-label="Form Steps" :readonly="false">
|
||||
basic: `<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)">
|
||||
|
@ -61,7 +71,12 @@ export default {
|
|||
options: `<template>
|
||||
<div>
|
||||
<div class="card">
|
||||
<Steps :model="items" aria-label="Form Steps" :readonly="false">
|
||||
<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)">
|
||||
|
@ -102,13 +117,23 @@ export default {
|
|||
}
|
||||
]
|
||||
}
|
||||
},
|
||||
methods: {
|
||||
isActive(item) {
|
||||
return item.route ? this.$router.resolve(item.route).path === this.$route.path : false;
|
||||
}
|
||||
}
|
||||
}
|
||||
<\/script>`,
|
||||
composition: `<template>
|
||||
<div>
|
||||
<div class="card">
|
||||
<Steps :model="items" aria-label="Form Steps" :readonly="false">
|
||||
<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)">
|
||||
|
@ -128,6 +153,10 @@ export default {
|
|||
|
||||
<script setup>
|
||||
import { ref } from "vue";
|
||||
import { useRouter, useRoute } from "vue-router";
|
||||
|
||||
const router = useRouter();
|
||||
const route = useRoute();
|
||||
|
||||
const items = ref([
|
||||
{
|
||||
|
@ -147,9 +176,18 @@ const items = ref([
|
|||
route: "/confirmation",
|
||||
}
|
||||
]);
|
||||
|
||||
const isActive = (item) => {
|
||||
return item.route ? router.resolve(item.route).path === route.path : false;
|
||||
}
|
||||
<\/script>`
|
||||
}
|
||||
};
|
||||
},
|
||||
methods: {
|
||||
isActive(item) {
|
||||
return item.route ? this.$router.resolve(item.route).path === this.$route.path : false;
|
||||
}
|
||||
}
|
||||
};
|
||||
</script>
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue