Skip to content

Commit eeeb9c9

Browse files
committed
docs(vue): update quickstart to include file names and start file paths from root
1 parent 9bc2371 commit eeeb9c9

File tree

3 files changed

+102
-105
lines changed

3 files changed

+102
-105
lines changed

docs/vue/quickstart.md

Lines changed: 34 additions & 35 deletions
Original file line numberDiff line numberDiff line change
@@ -53,28 +53,29 @@ After running `ionic serve`, your project will open in the browser.
5353

5454
## Explore the Project Structure
5555

56-
Your new app's `src` directory will look like this:
56+
Your new app's directory will look like this:
5757

5858
```shell
59-
├── App.vue
60-
├── main.ts
61-
├── router
62-
│   └── index.ts
63-
└── views
64-
   └── HomePage.vue
59+
└── src/
60+
├── App.vue
61+
├── main.ts
62+
├── router
63+
│   └── index.ts
64+
└── views
65+
   └── HomePage.vue
6566
```
6667

6768
:::info
68-
All file paths in the examples below are relative to the `src/` directory.
69+
All file paths in the examples below are relative to the project root directory.
6970
:::
7071

7172
Let's walk through these files to understand the app's structure.
7273

7374
## View the App Component
7475

75-
The root of your app is defined in `App.vue`:
76+
The root of your app is defined in `src/App.vue`:
7677

77-
```tsx
78+
```vue title="src/App.vue"
7879
<template>
7980
<ion-app>
8081
<ion-router-outlet />
@@ -90,9 +91,9 @@ This sets up the root of your application, using Ionic's `ion-app` and `ion-rout
9091

9192
## View Routes
9293

93-
Routes are defined in `router/index.ts`:
94+
Routes are defined in `src/router/index.ts`:
9495

95-
```ts
96+
```ts title="src/router/index.ts"
9697
import { createRouter, createWebHistory } from '@ionic/vue-router';
9798
import { RouteRecordRaw } from 'vue-router';
9899
import HomePage from '../views/HomePage.vue';
@@ -121,9 +122,9 @@ When you visit the root URL (`/`), the `HomePage` component will be loaded.
121122

122123
## View the Home Page
123124

124-
The Home page component, defined in `views/HomePage.vue`, imports the Ionic components and defines the page template:
125+
The Home page component, defined in `src/views/HomePage.vue`, imports the Ionic components and defines the page template:
125126

126-
```html
127+
```vue title="src/views/HomePage.vue"
127128
<template>
128129
<ion-page>
129130
<ion-header :translucent="true">
@@ -169,7 +170,7 @@ For detailed information about Ionic layout components, see the [Header](/docs/a
169170

170171
You can enhance your Home page with more Ionic UI components. For example, add a [Button](/docs/api/button) at the end of the `ion-content`:
171172

172-
```html
173+
```vue title="src/views/HomePage.vue"
173174
<ion-content>
174175
<!-- existing content -->
175176
@@ -179,17 +180,17 @@ You can enhance your Home page with more Ionic UI components. For example, add a
179180

180181
Then, import the `IonButton` component in the `<script>` tag:
181182

182-
```html
183+
```vue title="src/views/HomePage.vue"
183184
<script setup lang="ts">
184185
import { IonButton, IonContent, IonHeader, IonPage, IonTitle, IonToolbar } from '@ionic/vue';
185186
</script>
186187
```
187188

188189
## Add a New Page
189190

190-
Create a new page at `views/NewPage.vue`:
191+
Create a new page at `src/views/NewPage.vue`:
191192

192-
```html
193+
```vue title="src/views/NewPage.vue"
193194
<template>
194195
<ion-page>
195196
<ion-header :translucent="true">
@@ -218,23 +219,21 @@ Create a new page at `views/NewPage.vue`:
218219

219220
This creates a page with a [Back Button](/docs/api/back-button) in the [Toolbar](/docs/api/toolbar). The back button will automatically handle navigation back to the previous page, or to `/` if there is no history.
220221

221-
:::warning Important
222+
:::warning
222223
When creating your own pages, always use `ion-page` as the root component. This is essential for proper transitions between pages, base CSS styling that Ionic components depend on, and consistent layout behavior across your app.
223224
:::
224225

225226
## Navigate to the New Page
226227

227-
To navigate to the new page, create a route for it by first importing it at the top of `router/index.ts` after the `HomePage` import:
228+
To navigate to the new page, create a route for it by first importing it at the top of `src/router/index.ts` after the `HomePage` import:
228229

229-
To navigate to a new page, add the route to `router/index.ts`
230-
231-
```tsx
230+
```ts title="src/router/index.ts"
232231
import NewPage from '../views/NewPage.vue';
233232
```
234233

235234
Then, add its route in the `routes` array:
236235

237-
```tsx
236+
```ts title="src/router/index.ts"
238237
const routes: Array<RouteRecordRaw> = [
239238
{
240239
path: '/',
@@ -253,9 +252,9 @@ const routes: Array<RouteRecordRaw> = [
253252
];
254253
```
255254

256-
Once that is done, update the button in `views/HomePage.vue`:
255+
Once that is done, update the button in `src/views/HomePage.vue`:
257256

258-
```tsx
257+
```vue title="src/views/HomePage.vue"
259258
<ion-button router-link="/new">Navigate</ion-button>
260259
```
261260

@@ -267,9 +266,9 @@ Navigating can also be performed programmatically using Vue Router, and routes c
267266

268267
Ionic Vue comes with [Ionicons](https://ionic.io/ionicons/) pre-installed. You can use any icon by setting the `icon` property of the `ion-icon` component.
269268

270-
Update the imports in `views/NewPage.vue` to import `IonIcon` and the `heart` and `logoIonic` icons:
269+
Update the imports in `src/views/NewPage.vue` to import `IonIcon` and the `heart` and `logoIonic` icons:
271270

272-
```html
271+
```vue title="src/views/NewPage.vue"
273272
<script setup lang="ts">
274273
import { IonBackButton, IonButtons, IonContent, IonHeader, IonIcon, IonPage, IonTitle, IonToolbar } from '@ionic/vue';
275274
import { heart, logoIonic } from 'ionicons/icons';
@@ -278,7 +277,7 @@ Update the imports in `views/NewPage.vue` to import `IonIcon` and the `heart` an
278277

279278
Then, include them inside of the `ion-content`:
280279

281-
```tsx
280+
```vue title="src/views/NewPage.vue"
282281
<ion-icon :icon="heart"></ion-icon>
283282
<ion-icon :icon="logoIonic"></ion-icon>
284283
```
@@ -291,9 +290,9 @@ For more information, see the [Icon documentation](/docs/api/icon) and the [Ioni
291290

292291
Let's add a button that can scroll the content area to the bottom.
293292

294-
Update `views/NewPage.vue` to include a ref on `ion-content` and a button and some items after the existing icons:
293+
Update `src/views/NewPage.vue` to include a ref on `ion-content` and a button and some items after the existing icons:
295294

296-
```html
295+
```vue title="src/views/NewPage.vue"
297296
<ion-content ref="content">
298297
<ion-button @click="scrollToBottom">Scroll to Bottom</ion-button>
299298
@@ -306,7 +305,7 @@ Update `views/NewPage.vue` to include a ref on `ion-content` and a button and so
306305

307306
In the script section, add the new component imports and define the `scrollToBottom` function:
308307

309-
```html
308+
```vue title="src/views/NewPage.vue"
310309
<script setup lang="ts">
311310
import {
312311
IonBackButton,
@@ -371,15 +370,15 @@ Ionic Vue projects are created with TypeScript by default, but you can easily co
371370
npm uninstall --save typescript @types/jest @typescript-eslint/eslint-plugin @typescript-eslint/parser @vue/cli-plugin-typescript @vue/eslint-config-typescript vue-tsc
372371
```
373372

374-
2. Change the extension of all `.ts` files to `.js`. In a blank Ionic Vue app, this will be the `router/index.ts`, `main.ts`, and files in the `tests` directory.
373+
2. Change the extension of all `.ts` files to `.js`. In a blank Ionic Vue app, this will be the `src/router/index.ts`, `src/main.ts`, and files in the `tests` directory.
375374

376375
3. In `index.html`, change the imported `<script>` file from `/src/main.ts` to `/src/main.js`.
377376

378377
4. Remove `@vue/typescript/recommended` and `@typescript-eslint/no-explicit-any: 'off'` from `.eslintrc.js`.
379378

380-
5. Remove `Array<RouteRecordRaw>` and the import of `RouteRecordRaw` from `router/index.js`.
379+
5. Remove `Array<RouteRecordRaw>` and the import of `RouteRecordRaw` from `src/router/index.js`.
381380

382-
6. Remove `lang="ts"` from the `script` tags in any of your Vue components that have them. In a blank Ionic Vue app, this should only be `App.vue` and `views/HomePage.vue`.
381+
6. Remove `lang="ts"` from the `script` tags in any of your Vue components that have them. In a blank Ionic Vue app, this should only be `src/App.vue` and `src/views/HomePage.vue`.
383382

384383
7. Delete `tsconfig.json` and `vite-env.d.ts`.
385384

versioned_docs/version-v6/vue/quickstart.md

Lines changed: 34 additions & 35 deletions
Original file line numberDiff line numberDiff line change
@@ -53,28 +53,29 @@ After running `ionic serve`, your project will open in the browser.
5353

5454
## Explore the Project Structure
5555

56-
Your new app's `src` directory will look like this:
56+
Your new app's directory will look like this:
5757

5858
```shell
59-
├── App.vue
60-
├── main.ts
61-
├── router
62-
│   └── index.ts
63-
└── views
64-
   └── HomePage.vue
59+
└── src/
60+
├── App.vue
61+
├── main.ts
62+
├── router
63+
│   └── index.ts
64+
└── views
65+
   └── HomePage.vue
6566
```
6667

6768
:::info
68-
All file paths in the examples below are relative to the `src/` directory.
69+
All file paths in the examples below are relative to the project root directory.
6970
:::
7071

7172
Let's walk through these files to understand the app's structure.
7273

7374
## View the App Component
7475

75-
The root of your app is defined in `App.vue`:
76+
The root of your app is defined in `src/App.vue`:
7677

77-
```tsx
78+
```vue title="src/App.vue"
7879
<template>
7980
<ion-app>
8081
<ion-router-outlet />
@@ -90,9 +91,9 @@ This sets up the root of your application, using Ionic's `ion-app` and `ion-rout
9091

9192
## View Routes
9293

93-
Routes are defined in `router/index.ts`:
94+
Routes are defined in `src/router/index.ts`:
9495

95-
```ts
96+
```ts title="src/router/index.ts"
9697
import { createRouter, createWebHistory } from '@ionic/vue-router';
9798
import { RouteRecordRaw } from 'vue-router';
9899
import HomePage from '../views/HomePage.vue';
@@ -121,9 +122,9 @@ When you visit the root URL (`/`), the `HomePage` component will be loaded.
121122

122123
## View the Home Page
123124

124-
The Home page component, defined in `views/HomePage.vue`, imports the Ionic components and defines the page template:
125+
The Home page component, defined in `src/views/HomePage.vue`, imports the Ionic components and defines the page template:
125126

126-
```html
127+
```vue title="src/views/HomePage.vue"
127128
<template>
128129
<ion-page>
129130
<ion-header :translucent="true">
@@ -169,7 +170,7 @@ For detailed information about Ionic layout components, see the [Header](/docs/a
169170

170171
You can enhance your Home page with more Ionic UI components. For example, add a [Button](/docs/api/button) at the end of the `ion-content`:
171172

172-
```html
173+
```vue title="src/views/HomePage.vue"
173174
<ion-content>
174175
<!-- existing content -->
175176
@@ -179,17 +180,17 @@ You can enhance your Home page with more Ionic UI components. For example, add a
179180

180181
Then, import the `IonButton` component in the `<script>` tag:
181182

182-
```html
183+
```vue title="src/views/HomePage.vue"
183184
<script setup lang="ts">
184185
import { IonButton, IonContent, IonHeader, IonPage, IonTitle, IonToolbar } from '@ionic/vue';
185186
</script>
186187
```
187188

188189
## Add a New Page
189190

190-
Create a new page at `views/NewPage.vue`:
191+
Create a new page at `src/views/NewPage.vue`:
191192

192-
```html
193+
```vue title="src/views/NewPage.vue"
193194
<template>
194195
<ion-page>
195196
<ion-header :translucent="true">
@@ -218,23 +219,21 @@ Create a new page at `views/NewPage.vue`:
218219

219220
This creates a page with a [Back Button](/docs/api/back-button) in the [Toolbar](/docs/api/toolbar). The back button will automatically handle navigation back to the previous page, or to `/` if there is no history.
220221

221-
:::warning Important
222+
:::warning
222223
When creating your own pages, always use `ion-page` as the root component. This is essential for proper transitions between pages, base CSS styling that Ionic components depend on, and consistent layout behavior across your app.
223224
:::
224225

225226
## Navigate to the New Page
226227

227-
To navigate to the new page, create a route for it by first importing it at the top of `router/index.ts` after the `HomePage` import:
228+
To navigate to the new page, create a route for it by first importing it at the top of `src/router/index.ts` after the `HomePage` import:
228229

229-
To navigate to a new page, add the route to `router/index.ts`
230-
231-
```tsx
230+
```ts title="src/router/index.ts"
232231
import NewPage from '../views/NewPage.vue';
233232
```
234233

235234
Then, add its route in the `routes` array:
236235

237-
```tsx
236+
```ts title="src/router/index.ts"
238237
const routes: Array<RouteRecordRaw> = [
239238
{
240239
path: '/',
@@ -253,9 +252,9 @@ const routes: Array<RouteRecordRaw> = [
253252
];
254253
```
255254

256-
Once that is done, update the button in `views/HomePage.vue`:
255+
Once that is done, update the button in `src/views/HomePage.vue`:
257256

258-
```tsx
257+
```vue title="src/views/HomePage.vue"
259258
<ion-button router-link="/new">Navigate</ion-button>
260259
```
261260

@@ -267,9 +266,9 @@ Navigating can also be performed programmatically using Vue Router, and routes c
267266

268267
Ionic Vue comes with [Ionicons](https://ionic.io/ionicons/) pre-installed. You can use any icon by setting the `icon` property of the `ion-icon` component.
269268

270-
Update the imports in `views/NewPage.vue` to import `IonIcon` and the `heart` and `logoIonic` icons:
269+
Update the imports in `src/views/NewPage.vue` to import `IonIcon` and the `heart` and `logoIonic` icons:
271270

272-
```html
271+
```vue title="src/views/NewPage.vue"
273272
<script setup lang="ts">
274273
import { IonBackButton, IonButtons, IonContent, IonHeader, IonIcon, IonPage, IonTitle, IonToolbar } from '@ionic/vue';
275274
import { heart, logoIonic } from 'ionicons/icons';
@@ -278,7 +277,7 @@ Update the imports in `views/NewPage.vue` to import `IonIcon` and the `heart` an
278277

279278
Then, include them inside of the `ion-content`:
280279

281-
```tsx
280+
```vue title="src/views/NewPage.vue"
282281
<ion-icon :icon="heart"></ion-icon>
283282
<ion-icon :icon="logoIonic"></ion-icon>
284283
```
@@ -291,9 +290,9 @@ For more information, see the [Icon documentation](/docs/api/icon) and the [Ioni
291290

292291
Let's add a button that can scroll the content area to the bottom.
293292

294-
Update `views/NewPage.vue` to include a ref on `ion-content` and a button and some items after the existing icons:
293+
Update `src/views/NewPage.vue` to include a ref on `ion-content` and a button and some items after the existing icons:
295294

296-
```html
295+
```vue title="src/views/NewPage.vue"
297296
<ion-content ref="content">
298297
<ion-button @click="scrollToBottom">Scroll to Bottom</ion-button>
299298
@@ -306,7 +305,7 @@ Update `views/NewPage.vue` to include a ref on `ion-content` and a button and so
306305

307306
In the script section, add the new component imports and define the `scrollToBottom` function:
308307

309-
```html
308+
```vue title="src/views/NewPage.vue"
310309
<script setup lang="ts">
311310
import {
312311
IonBackButton,
@@ -371,15 +370,15 @@ Ionic Vue projects are created with TypeScript by default, but you can easily co
371370
npm uninstall --save typescript @types/jest @typescript-eslint/eslint-plugin @typescript-eslint/parser @vue/cli-plugin-typescript @vue/eslint-config-typescript vue-tsc
372371
```
373372

374-
2. Change the extension of all `.ts` files to `.js`. In a blank Ionic Vue app, this will be the `router/index.ts`, `main.ts`, and files in the `tests` directory.
373+
2. Change the extension of all `.ts` files to `.js`. In a blank Ionic Vue app, this will be the `src/router/index.ts`, `src/main.ts`, and files in the `tests` directory.
375374

376375
3. In `index.html`, change the imported `<script>` file from `/src/main.ts` to `/src/main.js`.
377376

378377
4. Remove `@vue/typescript/recommended` and `@typescript-eslint/no-explicit-any: 'off'` from `.eslintrc.js`.
379378

380-
5. Remove `Array<RouteRecordRaw>` and the import of `RouteRecordRaw` from `router/index.js`.
379+
5. Remove `Array<RouteRecordRaw>` and the import of `RouteRecordRaw` from `src/router/index.js`.
381380

382-
6. Remove `lang="ts"` from the `script` tags in any of your Vue components that have them. In a blank Ionic Vue app, this should only be `App.vue` and `views/HomePage.vue`.
381+
6. Remove `lang="ts"` from the `script` tags in any of your Vue components that have them. In a blank Ionic Vue app, this should only be `src/App.vue` and `src/views/HomePage.vue`.
383382

384383
7. Delete `tsconfig.json` and `vite-env.d.ts`.
385384

0 commit comments

Comments
 (0)