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

125 lines
3.1 KiB
Vue
Raw Normal View History

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