DemoTabsProgrammaticNavigation.vue
1.23 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
<script setup>
const currentTab = ref(1)
const items = [
'Appetizers',
'Entrees',
'Deserts',
'Cocktails',
]
const tabItemText = 'Chocolate cake marshmallow toffee sweet caramels tootsie roll chocolate bar. Chocolate candy lemon drops cupcake macaroon liquorice. Icing tiramisu cake pastry jujubes lollipop gummies sugar plum pie.'
const totalTabs = items.length
const preTab = () => {
if (currentTab.value !== 1)
currentTab.value -= 1
}
const nextTab = () => {
if (currentTab.value !== totalTabs)
currentTab.value += 1
}
</script>
<template>
<VTabs
v-model="currentTab"
grow
>
<VTab
v-for="item in items.length"
:key="item"
:value="item"
>
{{ items[item - 1] }}
</VTab>
</VTabs>
<VWindow
v-model="currentTab"
class="mt-5"
>
<VWindowItem
v-for="item in items.length"
:key="item"
:value="item"
>
{{ tabItemText }}
</VWindowItem>
</VWindow>
<div class="text-center">
<VBtn
variant="text"
:disabled="currentTab === 1"
@click="preTab"
>
Previous
</VBtn>
<VBtn
variant="text"
:disabled="currentTab === totalTabs"
@click="nextTab"
>
Next
</VBtn>
</div>
</template>