|
1 | 1 | # Multiple Tours |
2 | 2 | There are two ways to create multiple tours on the same page. You can either create multiple `VTour` components or create a single `VTour` component with multiple steps. |
3 | 3 |
|
4 | | -::: warning |
5 | | -This is an advanced feature and requires a good understanding of the `vuejs-tour` package. |
6 | | -::: |
7 | | - |
8 | 4 | ## Single Component |
9 | 5 | To create multiple tours using a single `VTour` component, you can use the `steps` and `name` prop to switch between different tours. |
10 | | -<div class="tip custom-block" style="padding-top: 8px"> |
11 | | -This is the recommended method for creating multiple tours on the same page. |
12 | | -</div> |
13 | 6 |
|
14 | 7 | ### Defining the tours |
15 | 8 | First you need to define the steps for each tour. |
@@ -64,68 +57,4 @@ To switch between tours, you just switch the `tourSteps` and `tourName` values. |
64 | 57 | ... |
65 | 58 | </template> |
66 | 59 | ``` |
67 | | -Now everytime you call the `switchTour` function, the tour will switch between `tour1` and `tour2`. |
68 | | -::: tip |
69 | | -There's no need to call `stopTour` before switching tours, the single `VTour` component will handle that for you. |
70 | | -::: |
71 | | - |
72 | | -## Multiple Components |
73 | | -You can create multiple `VTour` components with different steps and options. |
74 | | - |
75 | | -### Defining the tours |
76 | | -First you need to define the steps for each tour. |
77 | | -```vue{3-6,11-12} |
78 | | -<script setup lang='ts'> |
79 | | - ... |
80 | | - const steps = [...]; |
81 | | - const steps2 = [...]; |
82 | | - const vTour = ref(); |
83 | | - const vTour2 = ref(); |
84 | | - vTour.value.startTour(); |
85 | | -</script> |
86 | | -
|
87 | | -<template> |
88 | | - <VTour :steps="steps" ref="vTour" name="FirstTour"/> |
89 | | - <VTour :steps="steps2" ref="vTour2" name="SecondTour"/> |
90 | | - ... |
91 | | -</template> |
92 | | -``` |
93 | | -In this case we are creating two tours `vTour` and `vTour2`. |
94 | | -Each with their corresponding steps `steps` and `steps2`. |
95 | | - |
96 | | -### Switching between tours |
97 | | -To switch between tours, you just call the `startTour` method on the corresponding `VTour` component. |
98 | | -```vue{9-17} |
99 | | -<script setup lang='ts'> |
100 | | - ... |
101 | | - const steps = [...]; |
102 | | - const steps2 = [...]; |
103 | | - const vTour = ref(); |
104 | | - const vTour2 = ref(); |
105 | | - vTour.value.startTour(); |
106 | | - |
107 | | - function switchTour() { |
108 | | - if (vTour.value.isActive) { |
109 | | - vTour.value.stopTour(); |
110 | | - vTour2.value.startTour(); |
111 | | - } else { |
112 | | - vTour2.value.stopTour(); |
113 | | - vTour.value.startTour(); |
114 | | - } |
115 | | - } |
116 | | -</script> |
117 | | -
|
118 | | -<template> |
119 | | - <VTour :steps="steps" ref="vTour" name="FirstTour"/> |
120 | | - <VTour :steps="steps2" ref="vTour2" name="SecondTour"/> |
121 | | - ... |
122 | | -</template> |
123 | | -``` |
124 | | -Now everytime you call the `switchTour` function, the tour will switch between `tour1` and `tour2`. |
125 | | - |
126 | | -::: warning |
127 | | -When using multiple `VTour` components, it is possible to have multiple tours active at the same time. |
128 | | -Which may cause unexpected behavior and overlapping tours. |
129 | | - |
130 | | -This is why the single component method is recommended. |
131 | | -::: |
| 60 | +Now everytime you call the `switchTour` function, the tour will switch between `tour1` and `tour2`. |
0 commit comments