primevue-mirror/doc/accordion/pt/PTDoc.vue

125 lines
3.2 KiB
Vue
Raw Normal View History

<template>
2023-04-11 07:17:19 +00:00
<DocSectionText v-bind="$attrs"> </DocSectionText>
<div class="card">
2023-04-07 13:01:40 +00:00
<Accordion :activeIndex="0">
2023-04-11 07:17:19 +00:00
<AccordionTab
v-for="(tab, index) in tabs"
:key="tab.title"
:header="tab.title"
:pt="{
2023-04-19 08:13:06 +00:00
headerAction: ({ props, parent }) => ({
2023-04-11 07:17:19 +00:00
class: panelClass(props, parent, index)
})
}"
>
<p>{{ tab.content }}</p>
2023-04-07 13:01:40 +00:00
</AccordionTab>
</Accordion>
</div>
<DocSectionCode :code="code" />
</template>
<script>
export default {
data() {
return {
2023-04-11 07:17:19 +00:00
tabs: Array.from({ length: 3 }, (_, i) => ({
title: `Header ${i + 1}`,
content: `Tab ${i + 1} Content`
})),
code: {
basic: `
2023-04-07 13:01:40 +00:00
<Accordion :activeIndex="0">
2023-04-11 07:17:19 +00:00
<AccordionTab v-for="(tab, index) in tabs" :key="tab.title" :header="tab.title"
:pt="{
2023-04-19 08:13:06 +00:00
headerAction: ({ props, parent }) => ({
2023-04-11 07:17:19 +00:00
class: panelClass(props, parent, index)
})
}">
<p>{{ tab.content }}</p>
2023-04-07 13:01:40 +00:00
</AccordionTab>
</Accordion>`,
options: `
<template>
2023-04-07 13:01:40 +00:00
<div class="card">
<Accordion :activeIndex="0">
2023-04-11 07:17:19 +00:00
<AccordionTab v-for="(tab, index) in tabs" :key="tab.title" :header="tab.title"
:pt="{
2023-04-19 08:13:06 +00:00
headerAction: ({ props, parent }) => ({
2023-04-11 07:17:19 +00:00
class: panelClass(props, parent, index)
})
}">
<p>{{ tab.content }}</p>
2023-04-07 13:01:40 +00:00
</AccordionTab>
</Accordion>
</div>
</template>
<script>
2023-04-11 07:17:19 +00:00
export default {
data() {
return {
tabs: Array.from({ length: 3 }, (_, i) => ({
title: \`Header \${i + 1}\`,
content: \`Tab \${i + 1} Content\`
}))
}
},
methods: {
panelClass(props, parent, index) {
return [
{
'bg-primary': parent.state.d_activeIndex === index
}
];
}
}
}
<\/script>`,
composition: `
<template>
2023-04-07 13:01:40 +00:00
<div class="card">
<Accordion :activeIndex="0">
2023-04-11 07:17:19 +00:00
<AccordionTab v-for="(tab, index) in tabs" :key="tab.title" :header="tab.title"
:pt="{
2023-04-19 08:13:06 +00:00
headerAction: ({ props, parent }) => ({
2023-04-11 07:17:19 +00:00
class: panelClass(props, parent, index)
})
}">
<p>{{ tab.content }}</p>
2023-04-07 13:01:40 +00:00
</AccordionTab>
</Accordion>
</div>
</template>
<script setup>
2023-04-11 07:17:19 +00:00
import { ref } from 'vue';
const tabs = ref(Array.from({ length: 3 }, (_, i) => ({
title: \`Header \${i + 1}\`,
content: \`Tab \${i + 1} Content\`
})));
const panelClass = (props, parent, index) => {
return [
{
'bg-primary': parent.state.d_activeIndex === index
}
];
};
<\/script>`
}
};
2023-04-11 07:17:19 +00:00
},
methods: {
panelClass(props, parent, index) {
return [
{
'bg-primary': parent.state.d_activeIndex === index
}
];
}
}
};
</script>