primevue-mirror/apps/showcase/doc/accordion/DynamicDoc.vue

95 lines
2.7 KiB
Vue
Raw Normal View History

2023-04-11 07:17:19 +00:00
<template>
<DocSectionText v-bind="$attrs">
2024-04-24 22:43:09 +00:00
<p>AccordionPanel can be generated dynamically using the standard <i>v-for</i> directive.</p>
2023-04-11 07:17:19 +00:00
</DocSectionText>
<div class="card">
2024-04-24 22:43:09 +00:00
<Accordion value="0">
<AccordionPanel v-for="tab in tabs" :key="tab.title" :value="tab.value">
<AccordionHeader>{{ tab.title }}</AccordionHeader>
<AccordionContent>
<p class="m-0">{{ tab.content }}</p>
</AccordionContent>
</AccordionPanel>
2023-04-11 07:17:19 +00:00
</Accordion>
</div>
<DocSectionCode :code="code" />
</template>
<script>
export default {
data() {
return {
tabs: [
2024-04-24 22:43:09 +00:00
{ title: 'Title 1', content: 'Content 1', value: '0' },
{ title: 'Title 2', content: 'Content 2', value: '1' },
{ title: 'Title 3', content: 'Content 3', value: '2' }
2023-04-11 07:17:19 +00:00
],
code: {
2023-09-22 12:54:14 +00:00
basic: `
2024-04-24 22:43:09 +00:00
<Accordion value="0">
<AccordionPanel v-for="tab in tabs" :key="tab.title" :value="tab.value">
<AccordionHeader>{{ tab.title }}</AccordionHeader>
<AccordionContent>
<p class="m-0">{{ tab.content }}</p>
</AccordionContent>
</AccordionPanel>
2023-10-15 09:38:39 +00:00
</Accordion>
`,
2023-09-22 12:54:14 +00:00
options: `
<template>
2023-04-11 07:17:19 +00:00
<div class="card">
2024-04-24 22:43:09 +00:00
<Accordion value="0">
<AccordionPanel v-for="tab in tabs" :key="tab.title" :value="tab.value">
<AccordionHeader>{{ tab.title }}</AccordionHeader>
<AccordionContent>
<p class="m-0">{{ tab.content }}</p>
</AccordionContent>
</AccordionPanel>
2023-04-11 07:17:19 +00:00
</Accordion>
</div>
</template>
<script>
export default {
data() {
return {
tabs: [
2024-04-24 22:43:09 +00:00
{ title: 'Title 1', content: 'Content 1', value: '0' },
{ title: 'Title 2', content: 'Content 2', value: '1' },
{ title: 'Title 3', content: 'Content 3', value: '2' }
2023-04-11 07:17:19 +00:00
]
};
}
};
2023-10-15 09:38:39 +00:00
<\/script>
`,
2023-09-22 12:54:14 +00:00
composition: `
<template>
2023-04-11 07:17:19 +00:00
<div class="card">
2024-04-24 22:43:09 +00:00
<Accordion value="0">
<AccordionPanel v-for="tab in tabs" :key="tab.title" :value="tab.value">
<AccordionHeader>{{ tab.title }}</AccordionHeader>
<AccordionContent>
<p class="m-0">{{ tab.content }}</p>
</AccordionContent>
</AccordionPanel>
2023-04-11 07:17:19 +00:00
</Accordion>
</div>
</template>
<script setup>
import { ref } from 'vue';
const tabs = ref([
2024-04-24 22:43:09 +00:00
{ title: 'Title 1', content: 'Content 1', value: '0' },
{ title: 'Title 2', content: 'Content 2', value: '1' },
{ title: 'Title 3', content: 'Content 3', value: '2' }
2023-04-11 07:17:19 +00:00
]);
2023-10-15 09:38:39 +00:00
<\/script>
`
2023-04-11 07:17:19 +00:00
}
};
}
};
</script>