primevue-mirror/doc/accordion/DynamicDoc.vue

83 lines
2.1 KiB
Vue
Raw Normal View History

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