Upgrade to Pro
— share decks privately, control downloads, hide ads and more …
Speaker Deck
Sign up for free
Menu
Search
Features
All features
Private URLs
Password Protection
Custom URLS
Scheduled publishing
Remove Branding
Restrict embedding
Deck Collections
Notes
Features
All features
Private URLs
Password Protection
Custom URLS
Scheduled publishing
Remove Branding
Restrict embedding
Deck Collections
Notes
Explore
Featured decks
Featured speakers
Programming
Technology
Storyboards
Explore
Featured decks
Featured speakers
Programming
Technology
Storyboards
Pricing
Search
Sign in
Sign up for free
kansai-frontend-ug-2020
Search
Sponsored
·
Your Podcast. Everywhere. Effortlessly.
Share. Educate. Inspire. Entertain. You do you. We'll handle the rest.
→
kazuki-komori
July 17, 2020
Programming
210
3
Share
Embed
Copy iframe code
Copy JS code
Copy link
Start on current slide
kansai-frontend-ug-2020
kazuki-komori
July 17, 2020
More Decks by kazuki-komori
See All by kazuki-komori
Nsihika 中古マンション価格予測 2022春 Solution 共有会
kazuyan
0
380
技育祭 2022 Do'er 紹介
kazuyan
1
180
StartDash_LT.pdf
kazuyan
1
160
CA tech Challenge
kazuyan
0
170
技育展_Profill
kazuyan
0
150
Other Decks in Programming
See All in Programming
TiDB Cloudのカスタムコントローラーによるオートスケール対応
takaidohigasi
0
130
FreeBSDでZabbixを動かす
kenkino
0
310
テストを司るデーモンに会いに行く 〜隔離した仮想マシンでテストを通すまで〜
h1d3mun3
1
440
The Good Stuff, Not the Slop: Engineering High-Quality Android Apps with Modern AI Tooling
danybony
1
260
世界の中心で、AI(App Intents)をさけぶ ー App Intents中心設計の実践ガイド
touyou
0
610
巨大モノリシックアプリ モダン化大作戦
ktcryomm
1
1k
Augmenting AI with the Power of Jakarta EE
ivargrimstad
0
200
マイコン向けの軽量Ruby「PicoRuby」で各種デバイスを制御するネイティブアプリの実現手法
bash0c7
0
420
20260914 AIエージェント時代のPlatform Engineering LLM基盤とプロダクトの責務境界線
kanfab1
7
2.1k
LoopHub - ローカルで動く GitHub で、AI と共同開発
jugyo
1
560
Webの地図
yosuke_furukawa
PRO
6
4.6k
SREの越境 / SRE Collaboration
y0hgi
2
240
Featured
See All Featured
XXLCSS - How to scale CSS and keep your sanity
sugarenia
250
1.3M
Writing Fast Ruby
sferik
630
63k
How Fast Is Fast Enough? [PerfNow 2025]
tammyeverts
3
890
CSS Pre-Processors: Stylus, Less & Sass
bermonpainter
360
30k
Chrome DevTools: State of the Union 2024 - Debugging React & Beyond
addyosmani
10
1.3k
Building Experiences: Design Systems, User Experience, and Full Site Editing
marktimemedia
1
610
Producing Creativity
orderedlist
PRO
348
41k
Introduction to Domain-Driven Design and Collaborative software design
baasie
1
990
Mozcon NYC 2025: Stop Losing SEO Traffic
samtorres
1
550
Code Reviewing Like a Champion
maltzj
528
40k
Art, The Web, and Tiny UX
lynnandtonic
304
22k
Scaling GitHub
holman
464
140k
Transcript
Vue ×ionic 爆速モバイルアプリ制作 Kazuki-komori ⼩森 ⼀輝
本題の前に・・・ 僕について。。 名前 : ⼩森 ⼀輝 / Kazuki Komori ⼤学:同志社⼤学
⽂化情報学部 2回 専⾨:統計学・機械学習 Webエンジニア歴:9ヶ⽉ぐらい
本題の前に・・・ なぜWeb業界に? ゲームが好きでそこで蓄積した知⾒を⾃分のサイトで共有 したい! プラグラミングめっちゃ楽しい!! もっといろいろ知りたい!
Whatʼs ionic ? WEB系をふだん触っている⼈でも、モバイルアプリを作成できる しかも、ios / Android 両⽅に対応できる、クロスプラットフォーム
ionic とReact Nativeの⼤まかな違い (公式HPより抜粋) https://ionicframework.com/resources/articles/ionic-react-vs-react-native ・HTML CSS で任意のデザイ ンを可能に ・カスタマイズにはSwift
Kotlin の知識が必要 ・PWA のサポート ・本来の UI に似せて作成 (標準の Web 技術を使⽤) ・内部で標準の ios Android を 動作させるのでパフォーマンス が良いことも ・PWA のサポートなし
とりあえず Vue を使って動かしてみる $ vue create ionic-sampleApp $ npm install
@ionic/
[email protected]
$ npm run serve
IonicVueRouterを追加 import Vue from ‘vue’ import Home from ‘../views/Home.vue’ //Ionic
向けの Vue Router の拡張機能の追加 import { IonicVueRouter } from “@ionic/vue”; Vue.use(IonicVueRouter) const routes = [ // 省略 ] const router = new IonicVueRouter({ mode: 'history', base: process.env.BASE_URL, routes }) export default router router/index.js <template> <ion-app id="app"> <ion-vue-router /> </ion-app> </template> <script> export default { name: "home", }; </script> App.vue
Ionic プラグインの追加 // 省略 // Ionic系のプラグインを追加 import Ionic from '@ionic/vue'
import '@ionic/core/css/core.css' import '@ionic/core/css/ionic.bundle.css' Vue.use(Ionic) Vue.config.productionTip = false new Vue({ router, store, render: h => h(App) }).$mount('#app’) main.js 動いた!
UI コンポーネントを追加してみる https://ionicframework.com/docs/components 公式ドキュメントにUIコンポーネン トがたくさん掲載されている!
UI コンポーネントを追加してみる(Alert) <template> <ion-vue-page> <ion-button @click="presentAlertConfirm">アラートが出るボタン!</ion-button> <div v-if="!notice"> 通知が許可されていません! </div>
<div v-if="notice"> 通知が許可されました! </div> </ion-vue-page> </template>
Alertの動作 (ios版) <script> export default { //省略 methods: { presentAlertConfirm()
{ return this.$ionic.alertController .create({ cssClass: ‘my-custom-class’, header: ‘通知’, subHeader: ‘通知許可してくれたら嬉しい!', message: 'このアプリに通知を許可しますか?', buttons: [ { text: 'キャンセル', role: 'cancel', handler: () => { this.notice = false }, }, { text: 'OK', handler: () => { this.notice = true }, }, ], }) .then(a => a.present()) }, } } </script>
Alertの動作 (android版) <script> export default { //省略 methods: { presentAlertConfirm()
{ return this.$ionic.alertController .create({ cssClass: ‘my-custom-class’, header: ‘通知’, subHeader: ‘通知許可してくれたら嬉しい!', message: 'このアプリに通知を許可しますか?', buttons: [ { text: 'キャンセル', role: 'cancel', handler: () => { this.notice = false }, }, { text: 'OK', handler: () => { this.notice = true }, }, ], }) .then(a => a.present()) }, } } </script>
せっかくなので、簡単なアプリをつくってみる 作ったもの・・・ 楽天の商品検索API を使って、商品の値段と名前を表⽰してくれるアプリ
せっかくなので、簡単なアプリをつくってみる 必要な部品 - ヘッダー - 検索ボックス - 検索ボタン - 検索結果を表⽰する場所
- バリデーション - ローダー
ヘッダー、検索ボックスを追加 <template> <ion-toolbar> <ion-toolbar> <ion-title>検索ページ</ion-title> </ion-toolbar> <ion-searchbar animated></ion-searchbar> </ion-toolbar> </template>
<style scoped> ion-toolbar { --background: #BF0E00; } ion-searchbar { --background: #F3F3F3; } ion-title { --color: #ffffff; } </style>
ヘッダー、検索ボックスを追加 <ion-title> <ion-searchbar> <ion-toolbar> <ion-toolbar>
ヘッダー、検索ボックスを追加 <template> <div> <ion-searchbar animated :value="value" @change="value = $event.target.value, input()">
</ion-searchbar> </div> </template> <script> export default { data() { return { value: "" } }, methods: { input(){ this.$emit('input', this.value) } } } </script> <!-- 略-->
検索結果の実装 <div v-for="(val, idx) in data" :key="idx"> <ion-card> <img :src="val.image"
width="100"/> <ion-card-header> <ion-card-subtitle> <span class="cardName"> {{val.name}} </span> </ion-card-subtitle> <ion-card-title> <span class="cardPrice"> {{val.price}}円 </span> </ion-card-title> </ion-card-header> </ion-card> </div>
検索結果の実装 <img> <ion-card> <ion-card-header> <ion-card-subtitle> <ion-card-title>
ローダーを作ってみる onload(){ return this.$ionic.loadingController .create({ cssClass: 'my-custom-class', message: '更新中...', })
.then(loading => { return loading.present() }) }, offload(){ return this.$ionic.loadingController.dismiss() }
ローダーを使ってみる async search(val){ //ローダーを作動 await this.onload() try {//略 //API呼び出し const
{data} = await axios.get(URL) //データをよしなに操作 this.data = this.editData(data) await true //ローダーを停⽌ this.offload() } },
バリデーションの実装 エラーが出たら ローダーを⽌める!
バリデーションの実装 methods: { async search(val) { this.valid.blank = false this.valid.error
= false //ローダーを作動 await this.onload() if (val === ‘‘ ) { this.valid.blank = true this.valid.error = true this.offload() .catch((e) => { this.valid.error = true this.valid.message = e }) } if (!this.valid.error) { try { const {data} = await axios.get(URL) this.data = this.editData(data) await true //ローダーを停⽌ this.offload() } catch (e) { this.offload() this.valid.error = true this.valid.message = e } } <div v-if="valid.blank" class="valid"> <!-- 検索ボックスが空欄の時--> 検索ボックスに何か⼊⼒してください。 </div> <div v-if="valid.error" class="valid"> <!-- API系で何かしらのエラーが吐かれた時--> {{valid.message}} </div> data(){ return{ data: [], valid: { error: false, blank: false, message: '' } } },
バリデーションの実装 <div v-if="valid.blank" class="valid"> <!-- 検索ボックスが空欄の時--> 検索ボックスに何か⼊⼒してください。 </div> <div v-if="valid.error"
class="valid"> <!-- API系で何かしらのエラーが吐かれた時--> {{valid.message}} </div> 検索ボックスが空の時・・・ 「検索ボックスに何か⼊⼒してください」を表⽰ 通信系でのエラーの時・・・ そのままエラーメッセージを出す
完成品 iPhone X Pixel 2 XL
まとめ Angular で作成もしてみたけど、やっぱり Vue が書きやすい! v-model が使えないのは結構不便かも・・ ぜひお試しを! Webコード 1
つで両⽅の端末を実装してくれるとやっぱり速い!
Vue ×ionic 爆速モバイルアプリ制作 Sample App: https://front-end-kansai-kazuyan-sample-app.netlify.app Kazuki-komori ⼩森 ⼀輝 ソースコード:
https://github.com/kazuki-komori/ionic-vue-sample