You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
@@ -4,10 +4,10 @@ sidebar_label: Build Your First App
4
4
---
5
5
6
6
<head>
7
-
<title>Vue Step-by-Step Tutorial: Run Your First Ionic App with Vue</title>
7
+
<title>Build Your First Ionic Mobile App with Vue | Ionic Capacitor Camera</title>
8
8
<meta
9
9
name="description"
10
-
content="This Vue tutorial, teaches the fundamentals of Ionic app development by creating a realistic app step-by-step. Learn to run your first Ionic app with Vue."
10
+
content="This Vue tutorial teaches the fundamentals of Ionic app development by creating a realistic app step-by-step. Learn to run your first Ionic app with Vue."
11
11
/>
12
12
</head>
13
13
@@ -30,11 +30,11 @@ We'll create a Photo Gallery app that offers the ability to take photos with you
30
30
31
31
Highlights include:
32
32
33
-
- One Vue-based codebase that runs on the web, iOS, and Android using Ionic Framework [UI components](https://ionicframework.com/docs/components).
33
+
- One Vue-based codebase that runs on the web, iOS, and Android using Ionic Framework [UI components](../components.md).
34
34
- Deployed as a native iOS and Android mobile app using [Capacitor](https://capacitorjs.com), Ionic's official native app runtime.
35
-
- Photo Gallery functionality powered by the Capacitor [Camera](https://capacitorjs.com/docs/apis/camera), [Filesystem](https://capacitorjs.com/docs/apis/filesystem), and [Preferences](https://capacitorjs.com/docs/apis/preferences) APIs.
35
+
- Photo Gallery functionality powered by the Capacitor [Camera](../native/camera.md), [Filesystem](../native/filesystem.md), and [Preferences](../native/preferences.md) APIs.
36
36
37
-
Find the complete app code referenced in this guide [on GitHub](https://github.com/ionic-team/photo-gallery-capacitor-vue).
37
+
Find the [complete app code](https://github.com/ionic-team/tutorial-photo-gallery-vue) referenced in this guide on GitHub.
38
38
39
39
## Download Required Tools
40
40
@@ -43,9 +43,8 @@ Download and install these right away to ensure an optimal Ionic development exp
43
43
-**Node.js** for interacting with the Ionic ecosystem. [Download the LTS version here](https://nodejs.org/en/).
44
44
-**A code editor** for... writing code! We are fans of [Visual Studio Code](https://code.visualstudio.com/).
45
45
-**Command-line interface/terminal (CLI)**:
46
-
-**Windows** users: for the best Ionic experience, we recommend the built-in command line (cmd) or the Powershell
47
-
CLI, running in Administrator mode.
48
-
-**Mac/Linux** users, virtually any terminal will work.
46
+
-**Windows** users: for the best Ionic experience, we recommend the built-in command line (cmd) or the Powershell CLI, running in Administrator mode.
47
+
-**Mac/Linux** users: virtually any terminal will work.
49
48
50
49
## Install Ionic Tooling
51
50
@@ -56,7 +55,7 @@ To open a terminal in Visual Studio Code, go to Terminal -> New Terminal.
Some Capacitor plugins, including the Camera API, provide the web-based functionality and UI via the Ionic [PWA Elements library](https://github.com/ionic-team/pwa-elements).
91
+
Some Capacitor plugins, including the [Camera API](../native/camera.md), provide the web-based functionality and UI via the Ionic [PWA Elements library](https://github.com/ionic-team/pwa-elements).
93
92
94
93
It's a separate dependency, so install it next:
95
94
96
95
```shell
97
96
npm install @ionic/pwa-elements
98
97
```
99
98
100
-
After installation, open up the project in your code editor of choice.
101
-
102
99
Next, import `@ionic/pwa-elements` by editing `src/main.ts`.
That’s it! Now for the fun part - let’s see the app in action.
111
126
112
127
## Run the App
113
128
114
-
Run this command in your shell:
129
+
Run this command next:
115
130
116
131
```shell
117
132
ionic serve
118
133
```
119
134
120
135
And voilà! Your Ionic app is now running in a web browser. Most of your app can be built and tested right in the browser, greatly increasing development and testing speed.
121
136
122
-
## Photo Gallery!!!
137
+
## Photo Gallery
123
138
124
-
There are three tabs. Click on the Tab2 tab. It’s a blank canvas, aka the perfect spot to transform into a Photo Gallery. The Ionic CLI features Live Reload, so when you make changes and save them, the app is updated immediately!
139
+
There are three tabs. Click on the "Tab2" tab. It’s a blank canvas, aka the perfect spot to transform into a Photo Gallery. The Ionic CLI features Live Reload, so when you make changes and save them, the app is updated immediately!
125
140
126
141

127
142
128
-
Open `/src/views/Tab2.vue`. We see:
143
+
Open `/src/views/Tab2Page.vue`. We see:
129
144
130
-
```html
145
+
```vue
131
146
<template>
132
147
<ion-page>
133
148
<ion-header>
@@ -146,94 +161,112 @@ Open `/src/views/Tab2.vue`. We see:
146
161
</ion-content>
147
162
</ion-page>
148
163
</template>
164
+
165
+
<script setup lang="ts">
166
+
import { IonPage, IonHeader, IonToolbar, IonTitle, IonContent } from '@ionic/vue';
167
+
import ExploreContainer from '@/components/ExploreContainer.vue';
168
+
</script>
149
169
```
150
170
151
-
`ion-header` represents the top navigation and toolbar, with "Tab 2" as the title. Let’s rename it:
171
+
`ion-header` represents the top navigation and toolbar, with "Tab 2" as the title (there are two of them due to iOS [Collapsible Large Title](../api/title.md#collapsible-large-titles) support). Rename both `ion-title` elements to:
152
172
153
-
```html
173
+
```vue
154
174
<template>
155
175
<ion-page>
156
176
<ion-header>
157
177
<ion-toolbar>
158
-
<!-- CHANGE: Update title.-->
178
+
<!-- CHANGE: Update title -->
159
179
<ion-title>Photo Gallery</ion-title>
160
180
</ion-toolbar>
161
181
</ion-header>
162
182
<ion-content :fullscreen="true">
163
183
<ion-header collapse="condense">
164
184
<ion-toolbar>
165
-
<!-- CHANGE: Update title.-->
185
+
<!-- CHANGE: Update title -->
166
186
<ion-title size="large">Photo Gallery</ion-title>
167
187
</ion-toolbar>
168
188
</ion-header>
169
189
170
-
<ExploreContainername="Tab 2 page" />
190
+
<!-- ...existing code... -->
171
191
</ion-content>
172
192
</ion-page>
173
193
</template>
174
194
```
175
195
176
-
We put the visual aspects of our app into `<ion-content>`. In this case, it’s where we’ll add a button that opens the device’s camera as well as displays the image captured by the camera. But first, remove the `ExploreContainer` component, beginning with the import statement:
196
+
We put the visual aspects of our app into `<ion-content>`. In this case, it’s where we’ll add a button that opens the device’s camera as well as displays the image captured by the camera. Start by adding a [floating action button](../api/fab.md) (FAB) to the bottom of the page and set the camera image as the icon.
Next, remove the `ExploreContainer` node from the HTML markup in the `template`.
183
-
184
-
```html
185
-
<ExploreContainername="Tab 2 page" />
186
-
```
187
-
188
-
We'll replace it with a [floating action button](https://ionicframework.com/docs/api/fab) (FAB). First, update the imports within the `<script setup>` tag to include the Camera icon as well as some of the Ionic components we'll use shortly:
189
-
190
-
```tsx
191
-
import { camera, trash, close } from'ionicons/icons';
192
-
import {
193
-
IonPage,
194
-
IonHeader,
195
-
IonFab,
196
-
IonFabButton,
197
-
IonIcon,
198
-
IonToolbar,
199
-
IonTitle,
200
-
IonContent,
201
-
IonGrid,
202
-
IonRow,
203
-
IonCol,
204
-
IonImg,
205
-
} from'@ionic/vue';
206
-
```
198
+
```vue
199
+
<template>
200
+
<ion-page>
201
+
<ion-header>
202
+
<ion-toolbar>
203
+
<ion-title>Photo Gallery</ion-title>
204
+
</ion-toolbar>
205
+
</ion-header>
206
+
<ion-content :fullscreen="true">
207
+
<ion-header collapse="condense">
208
+
<ion-toolbar>
209
+
<ion-title size="large">Photo Gallery</ion-title>
210
+
</ion-toolbar>
211
+
</ion-header>
207
212
208
-
Since our pages are generated as [Vue Single File Components](https://vuejs.org/api/sfc-spec.html) using the [`<script setup>`](https://vuejs.org/api/sfc-script-setup.html#script-setup) syntax these items are now exposed for use in our template.
Add the FAB to the bottom of the page. Use the camera image as the icon, and call the `takePhoto()` function when this button is clicked (to be implemented soon):
220
+
<!-- CHANGE: Remove or comment out <ExploreContainer /> -->
// CHANGE: Update import by removing `ellipse` and adding `images`
227
268
import { images, square, triangle } from 'ionicons/icons';
269
+
</script>
228
270
```
229
271
230
-
Within the tab bar (`<ion-tab-bar>`), change the label to "Photos" and the `ellipse` icon to `images` for the middle tab button:
231
-
232
-
```html
233
-
<ion-tab-buttontab="tab2"href="/tabs/tab2">
234
-
<ion-icon:icon="images" />
235
-
<ion-label>Photos</ion-label>
236
-
</ion-tab-button>
237
-
```
238
-
239
-
That’s just the start of all the cool things we can do with Ionic. Up next, implementing camera taking functionality on the web, then building for iOS and Android.
272
+
That’s just the start of all the cool things we can do with Ionic. Up next, implement camera taking functionality on the web, then build it for iOS and Android.
0 commit comments