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
kazuki-komori
July 17, 2020
Programming
220
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
390
技育祭 2022 Do'er 紹介
kazuyan
1
180
StartDash_LT.pdf
kazuyan
1
170
CA tech Challenge
kazuyan
0
170
技育展_Profill
kazuyan
0
150
Other Decks in Programming
See All in Programming
Kawaiicon: Kubernetes, it's no longer cool, but let's secure it anyway!
barnbarn
0
130
ActionController meets Protocol Buffers
sorah
1
800
Kotlinize Is Not Just Converting to Kotlin
chigichan24
1
220
Engineering Biometric UX Across Android Versions | DroidKnights 2026
ryunen344
1
190
私なりのハーネスエンジニアリング ~独自の言語処理系の開発を通して~
seosoft
0
200
オーケストレーション記述言語 Katari
yukikurage
0
240
當我們開始不讀 Code - AI Agent 時代,Code Review 與 Clean Code 還剩下什麼?
jame2408
1
370
LLM 101: Exploring LLMs, Starting with Tokens.
dalinaum
0
100
React Native에 현대적인 빌드 도구 더하기: Rollipop 구현기
leegeunhyeok
0
180
エージェントを使い続けるためのメタワーク / Meta-work for keeping using the agent
rkaga
6
2.2k
AWS CDKを理解するために公式の定義を深掘って解説してみる / Understanding AWS CDK by Digging into Its Official Definition
akihisaikeda
3
290
Rails初心者がパスキーを実装してみて大変だったこと
ktombow
0
160
Featured
See All Featured
Designing Experiences People Love
moore
143
24k
Lightning talk: Run Django tests with GitHub Actions
sabderemane
0
320
How to build a perfect <img>
jonoalderson
1
6.2k
Imperfection Machines: The Place of Print at Facebook
scottboms
270
14k
sira's awesome portfolio website redesign presentation
elsirapls
0
500
I Don’t Have Time: Getting Over the Fear to Launch Your Podcast
jcasabona
35
2.9k
Building a Scalable Design System with Sketch
lauravandoore
464
34k
Testing 201, or: Great Expectations
jmmastey
46
8.4k
Design of three-dimensional binary manipulators for pick-and-place task avoiding obstacles (IECON2024)
konakalab
0
650
Marketing Yourself as an Engineer | Alaka | Gurzu
gurzu
0
370
Rebuilding a faster, lazier Slack
samanthasiow
85
9.7k
What’s in a name? Adding method to the madness
productmarketing
PRO
24
4.2k
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