Upgrade to Pro
— share decks privately, control downloads, hide ads and more …
Speaker Deck
Features
Speaker Deck
PRO
Sign in
Sign up for free
Search
Search
kansai-frontend-ug-2020
Search
Sponsored
·
Ship Features Fearlessly
Turn features on and off without deploys. Used by thousands of Ruby developers.
→
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
370
技育祭 2022 Do'er 紹介
kazuyan
1
170
StartDash_LT.pdf
kazuyan
1
160
CA tech Challenge
kazuyan
0
160
技育展_Profill
kazuyan
0
150
Other Decks in Programming
See All in Programming
PHP Application における Kubernetes 内 gRPC 通信
ganchiku
0
500
Even G2とAWSで推しのエージェントを召喚しよう!
har1101
1
170
分散システム、なんですぐ死んでしまうん?耐障害性を高めたいあなたのためのレジリエンスパターン入門
mshibuya
7
6.4k
琵琶湖の水は止められてもNet--HTTPのリトライは止められない / You might be able to stop the water flow of Lake Biwa but you can't stop Net::HTTP retries
luccafort
PRO
0
400
技術記事、 専門家としてのプログラマ、 言語化
mizchi
14
7.5k
型も通る、synthも通る、それでも危ない 〜AIのCDKの権限とコストを機械で検証する〜 / It Passes Type Checks, It Passes Synth Checks, but It’s Still Risky — Automatically Verifying Permissions and Costs in AI’s CDK —
seike460
PRO
1
360
エンジニアにデザインハーネスを 〜デザインプロセスを規定するためのハーネス〜 / Design harness from an engineer's perspective
rkaga
2
1.5k
Embedded SREと共に達成した会員管理システムのAWS移行 - SRE NEXT 2026 ランチスポンサーセッション
niftycorp
PRO
1
2.7k
ソフトウェア設計に溶けるインフラ ― AWS CDK のインフラ認識論
konokenj
2
550
yield再入門 #phpcon
o0h
PRO
0
560
えっ!!コードを読まずに開発を!?
hananouchi
0
220
Haskell/Servantを通してWebミドルウェアを捉え直す
pizzacat83
1
590
Featured
See All Featured
Connecting the Dots Between Site Speed, User Experience & Your Business [WebExpo 2025]
tammyeverts
11
970
Save Time (by Creating Custom Rails Generators)
garrettdimon
PRO
32
3.9k
What's in a price? How to price your products and services
michaelherold
247
13k
End of SEO as We Know It (SMX Advanced Version)
ipullrank
3
4.3k
Six Lessons from altMBA
skipperchong
29
4.3k
Building an army of robots
kneath
306
46k
Dominate Local Search Results - an insider guide to GBP, reviews, and Local SEO
greggifford
PRO
0
210
No one is an island. Learnings from fostering a developers community.
thoeni
21
3.8k
The B2B funnel & how to create a winning content strategy
katarinadahlin
PRO
1
420
Templates, Plugins, & Blocks: Oh My! Creating the theme that thinks of everything
marktimemedia
31
2.8k
Exploring the Power of Turbo Streams & Action Cable | RailsConf2023
kevinliebholz
37
6.5k
Crafting Experiences
bethany
1
220
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