Skip to content

Commit 9e16649

Browse files
committed
docs(vue): update all script references in the docs to use setup
1 parent 5dbb380 commit 9e16649

22 files changed

+251
-765
lines changed

docs/api/tab-bar.md

Lines changed: 2 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -130,17 +130,9 @@ export const TabBarExample: React.FC = () => (
130130
</ion-tabs>
131131
</template>
132132

133-
<script>
133+
<script setup lang="ts">
134134
import { IonIcon, IonTabBar, IonTabButton, IonTabs } from '@ionic/vue';
135135
import { call, person, settings } from 'ionicons/icons';
136-
import { defineComponent } from 'vue';
137-
138-
export default defineComponent({
139-
components: { IonIcon, IonTabBar, IonTabButton, IonTabs },
140-
setup() {
141-
return { call, person, settings }
142-
}
143-
});
144136
</script>
145137
```
146138

@@ -176,4 +168,4 @@ import InsideTabBar from '@site/static/usage/v8/badge/inside-tab-bar/index.md';
176168
<CustomProps />
177169

178170
## Slots
179-
<Slots />
171+
<Slots />

docs/api/tab-button.md

Lines changed: 8 additions & 22 deletions
Original file line numberDiff line numberDiff line change
@@ -12,7 +12,7 @@ import CustomProps from '@ionic-internal/component-api/v8/tab-button/custom-prop
1212
import Slots from '@ionic-internal/component-api/v8/tab-button/slots.md';
1313

1414

15-
15+
1616
import EncapsulationPill from '@components/page/api/EncapsulationPill';
1717

1818
<EncapsulationPill type="shadow" />
@@ -166,7 +166,7 @@ export const TabButtonExample: React.FC = () => (
166166
</ion-tab-button>
167167

168168
<ion-tab-button tab="speakers" href="/tabs/speakers">
169-
<ion-icon :icon="person-circle" aria-hidden="true"></ion-icon>
169+
<ion-icon :icon="personCircle" aria-hidden="true"></ion-icon>
170170
<ion-label>Speakers</ion-label>
171171
</ion-tab-button>
172172

@@ -183,29 +183,15 @@ export const TabButtonExample: React.FC = () => (
183183
</ion-tabs>
184184
</template>
185185

186-
<script>
187-
import {
188-
IonIcon,
189-
IonLabel,
190-
IonTabBar,
191-
IonTabButton,
186+
<script setup lang="ts">
187+
import {
188+
IonIcon,
189+
IonLabel,
190+
IonTabBar,
191+
IonTabButton,
192192
IonTabs
193193
} from '@ionic/vue';
194194
import { calendar, informationCircle, map, personCircle } from 'ionicons/icons';
195-
import { defineComponent } from 'vue';
196-
197-
export default defineComponent({
198-
components: {
199-
IonIcon,
200-
IonLabel,
201-
IonTabBar,
202-
IonTabButton,
203-
IonTabs
204-
},
205-
setup() {
206-
return { calendar, informationCircle, map, personCircle }
207-
}
208-
});
209195
</script>
210196
```
211197

docs/developing/hardware-back-button.md

Lines changed: 15 additions & 27 deletions
Original file line numberDiff line numberDiff line change
@@ -122,13 +122,9 @@ import { useBackButton } from '@ionic/vue';
122122
123123
...
124124
125-
export default {
126-
setup() {
127-
useBackButton(10, () => {
128-
console.log('Handler was called!');
129-
});
130-
}
131-
}
125+
useBackButton(10, () => {
126+
console.log('Handler was called!');
127+
});
132128
```
133129
</TabItem>
134130
</Tabs>
@@ -236,19 +232,15 @@ import { useBackButton } from '@ionic/vue';
236232
237233
...
238234
239-
export default {
240-
setup() {
241-
useBackButton(5, () => {
242-
console.log('Another handler was called!');
243-
});
235+
useBackButton(5, () => {
236+
console.log('Another handler was called!');
237+
});
244238
245-
useBackButton(10, (processNextHandler) => {
246-
console.log('Handler was called!');
239+
useBackButton(10, (processNextHandler) => {
240+
console.log('Handler was called!');
247241
248-
processNextHandler();
249-
});
250-
}
251-
}
242+
processNextHandler();
243+
});
252244
```
253245
</TabItem>
254246
</Tabs>
@@ -385,16 +377,12 @@ import { App } from '@capacitor/app';
385377
386378
...
387379
388-
export default {
389-
setup() {
390-
const ionRouter = useIonRouter();
391-
useBackButton(-1, () => {
392-
if (!ionRouter.canGoBack()) {
393-
App.exitApp();
394-
}
395-
});
380+
const ionRouter = useIonRouter();
381+
useBackButton(-1, () => {
382+
if (!ionRouter.canGoBack()) {
383+
App.exitApp();
396384
}
397-
}
385+
});
398386
```
399387
</TabItem>
400388
</Tabs>

docs/updating/6-0.md

Lines changed: 2 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -196,13 +196,8 @@ This applies to `ion-action-sheet`, `ion-alert`, `ion-loading`, `ion-modal`, `io
196196
<ion-tab-bar slot="bottom"> ... </ion-tab-bar>
197197
</ion-tabs>
198198

199-
<script>
199+
<script setup lang="ts">
200200
import { IonTabs, IonTabBar } from '@ionic/vue';
201-
import { defineComponent } from 'vue';
202-
203-
export default defineComponent({
204-
components: { IonTabs, IonTabBar },
205-
});
206201
</script>
207202
```
208203

@@ -214,13 +209,8 @@ This applies to `ion-action-sheet`, `ion-alert`, `ion-loading`, `ion-modal`, `io
214209
<ion-tab-bar slot="bottom"> ... </ion-tab-bar>
215210
</ion-tabs>
216211

217-
<script>
212+
<script setup lang="ts">
218213
import { IonTabs, IonTabBar, IonRouterOutlet } from '@ionic/vue';
219-
import { defineComponent } from 'vue';
220-
221-
export default defineComponent({
222-
components: { IonTabs, IonTabBar, IonRouterOutlet },
223-
});
224214
</script>
225215
```
226216

docs/vue/lifecycle.md

Lines changed: 35 additions & 44 deletions
Original file line numberDiff line numberDiff line change
@@ -22,60 +22,51 @@ These lifecycles are only called on components directly mapped by a router. This
2222
The lifecycles are defined the same way Vue lifecycle methods are - as functions at the root of your Vue component:
2323

2424
```tsx
25+
<script setup lang="ts">
2526
import { IonPage } from '@ionic/vue';
26-
import { defineComponent } from 'vue';
27-
28-
export default defineComponent({
29-
name: 'Home',
30-
ionViewDidEnter() {
31-
console.log('Home page did enter');
32-
},
33-
ionViewDidLeave() {
34-
console.log('Home page did leave');
35-
},
36-
ionViewWillEnter() {
37-
console.log('Home page will enter');
38-
},
39-
ionViewWillLeave() {
40-
console.log('Home page will leave');
41-
},
42-
components: {
43-
IonPage,
44-
},
45-
});
27+
28+
const ionViewDidEnter = () => {
29+
console.log('Home page did enter');
30+
};
31+
32+
const ionViewDidLeave = () => {
33+
console.log('Home page did leave');
34+
};
35+
36+
const ionViewWillEnter = () => {
37+
console.log('Home page will enter');
38+
};
39+
40+
const ionViewWillLeave = () => {
41+
console.log('Home page will leave');
42+
};
43+
</script>
4644
```
4745

4846
### Composition API Hooks
4947

5048
These lifecycles can also be expressed using Vue 3's Composition API:
5149

5250
```tsx
51+
<script setup lang="ts">
5352
import { IonPage, onIonViewWillEnter, onIonViewDidEnter, onIonViewWillLeave, onIonViewDidLeave } from '@ionic/vue';
54-
import { defineComponent } from 'vue';
55-
56-
export default defineComponent({
57-
name: 'Home',
58-
components: {
59-
IonPage,
60-
},
61-
setup() {
62-
onIonViewDidEnter(() => {
63-
console.log('Home page did enter');
64-
});
65-
66-
onIonViewDidLeave(() => {
67-
console.log('Home page did leave');
68-
});
69-
70-
onIonViewWillEnter(() => {
71-
console.log('Home page will enter');
72-
});
73-
74-
onIonViewWillLeave(() => {
75-
console.log('Home page will leave');
76-
});
77-
},
53+
54+
onIonViewDidEnter(() => {
55+
console.log('Home page did enter');
56+
});
57+
58+
onIonViewDidLeave(() => {
59+
console.log('Home page did leave');
60+
});
61+
62+
onIonViewWillEnter(() => {
63+
console.log('Home page will enter');
64+
});
65+
66+
onIonViewWillLeave(() => {
67+
console.log('Home page will leave');
7868
});
69+
</script>
7970
```
8071

8172
:::note

0 commit comments

Comments
 (0)