primevue-mirror/doc/tabview/DynamicDoc.vue

80 lines
2.0 KiB
Vue
Raw Normal View History

2023-02-28 08:29:30 +00:00
<template>
<DocSectionText v-bind="$attrs">
<p>Tabs can be generated dynamically using the standard <i>v-for</i> directive.</p>
</DocSectionText>
<div class="card">
<TabView>
<TabPanel v-for="tab in tabs" :key="tab.title" :header="tab.title">
<p>{{ tab.content }}</p>
</TabPanel>
</TabView>
</div>
<DocSectionCode :code="code" />
</template>
<script>
export default {
data() {
return {
tabs: [
{ title: 'Tab 1', content: 'Tab 1 Content' },
{ title: 'Tab 2', content: 'Tab 2 Content' },
{ title: 'Tab 3', content: 'Tab 3 Content' }
],
code: {
2023-09-22 12:54:14 +00:00
basic: `
<TabView>
2023-02-28 08:29:30 +00:00
<TabPanel v-for="tab in tabs" :key="tab.title" :header="tab.title">
<p>{{ tab.content }}</p>
</TabPanel>
2023-03-09 11:39:38 +00:00
</TabView>`,
2023-09-22 12:54:14 +00:00
options: `
<template>
2023-03-09 11:39:38 +00:00
<div class="card">
2023-02-28 08:29:30 +00:00
<TabView>
<TabPanel v-for="tab in tabs" :key="tab.title" :header="tab.title">
<p>{{ tab.content }}</p>
</TabPanel>
</TabView>
</div>
</template>
<script>
export default {
data() {
return {
tabs: [
{ title: 'Tab 1', content: 'Tab 1 Content' },
{ title: 'Tab 2', content: 'Tab 2 Content' },
{ title: 'Tab 3', content: 'Tab 3 Content' }
]
};
}
};
2023-03-09 11:39:38 +00:00
<\/script>`,
2023-09-22 12:54:14 +00:00
composition: `
<template>
2023-03-09 11:39:38 +00:00
<div class="card">
2023-02-28 08:29:30 +00:00
<TabView>
<TabPanel v-for="tab in tabs" :key="tab.title" :header="tab.title">
<p>{{ tab.content }}</p>
</TabPanel>
</TabView>
</div>
</template>
<script setup>
import { ref } from 'vue';
const tabs = ref([
{ title: 'Tab 1', content: 'Tab 1 Content' },
{ title: 'Tab 2', content: 'Tab 2 Content' },
{ title: 'Tab 3', content: 'Tab 3 Content' }
]);
2023-03-09 11:39:38 +00:00
<\/script>`
2023-02-28 08:29:30 +00:00
}
};
}
};
</script>