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
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
WebRTC映像をAirPlayに対応させる挑戦.pdf
monolithic_adam
0
340
動作中のプログラムの中身をリアルタイムに覗く / Realtime Debugger for CSharp with Roslyn
prota
1
1.8k
残高管理から台帳サービスへの進化
artoy
0
160
機械に任せるテスト、人が見るテスト ⽣成AIで引き直した、運⽤保守フェーズの線引き
dske104
0
160
Starting & Sustaining Code-Based E2E Testing for Non-Coding QA Teams( #jasstniigata )
teyamagu
PRO
1
910
仕様駆動開発による爆速プロダクト開発 / Bakusoku Spec Driven Development
kobakei
0
200
Heart of Swift Concurrency
koher
0
1.2k
速習iPhone Duo対応
yuukiw00w
2
960
パーソナライズPodcastを作った話
repunit11
0
120
ソニーのクラウド共通基盤の変遷とAI時代の開発スタイルに合わせた進化 / The Journey of Sony’s Common Cloud Platform and Its Evolution for AI-Native Development
kenjiyoneyama
0
230
iOS 27でニュースアプリはどう変わる!? 〜日経電子版の新機能対応と、開発事例から〜
lynnswap
7
13k
Findy - エンジニア向け会社紹介/Findy Company Deck
findyinc
6
400k
Featured
See All Featured
Applied NLP in the Age of Generative AI
inesmontani
PRO
4
2.5k
Building AI with AI
inesmontani
PRO
1
1.3k
Faster Mobile Websites
deanohume
310
32k
HU Berlin: Industrial-Strength Natural Language Processing with spaCy and Prodigy
inesmontani
PRO
0
740
The Language of Interfaces
destraynor
162
27k
Neural Spatial Audio Processing for Sound Field Analysis and Control
skoyamalab
0
540
It's Worth the Effort
3n
188
29k
Lightning talk: Run Django tests with GitHub Actions
sabderemane
0
290
世界の人気アプリ100個を分析して見えたペイウォール設計の心得
akihiro_kokubo
PRO
74
42k
Design in an AI World
tapps
1
350
Git: the NoSQL Database
bkeepers
PRO
433
67k
The Illustrated Children's Guide to Kubernetes
chrisshort
51
53k
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