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
vue_js_composition_api
Search
Sponsored
·
Your Podcast. Everywhere. Effortlessly.
Share. Educate. Inspire. Entertain. You do you. We'll handle the rest.
→
Hirofumi Horiuchi
May 25, 2020
71
0
Share
Embed
Copy iframe code
Copy JS code
Copy link
Start on current slide
vue_js_composition_api
Hirofumi Horiuchi
May 25, 2020
More Decks by Hirofumi Horiuchi
See All by Hirofumi Horiuchi
Stimulusのはなし
h_reader
0
43
同じってなんだ?
h_reader
0
40
OSSを読んでみた?
h_reader
0
59
秒速でリリースするWebアプリ.pdf
h_reader
0
53
はじめよう async/await
h_reader
0
55
Node.jsではじめるオレオレツールの世界
h_reader
0
520
Featured
See All Featured
Building Applications with DynamoDB
mza
96
7.2k
How Software Deployment tools have changed in the past 20 years
geshan
1
34k
Into the Great Unknown - MozCon
thekraken
41
2.7k
Mobile First: as difficult as doing things right
swwweet
225
10k
The SEO Collaboration Effect
kristinabergwall1
1
550
The Impact of AI in SEO - AI Overviews June 2024 Edition
aleyda
6
1.2k
Site-Speed That Sticks
csswizardry
13
1.5k
4 Signs Your Business is Dying
shpigford
187
23k
How STYLIGHT went responsive
nonsquared
100
6.3k
Put a Button on it: Removing Barriers to Going Fast.
kastner
60
4.6k
Future Trends and Review - Lecture 12 - Web Technologies (1019888BNR)
signer
PRO
0
3.7k
GraphQLとの向き合い方2022年版
quramy
50
15k
Transcript
Vue.js の新機能 Composition APIを 使ってみた Tried using Composition API which
is a new feature of Vue.js
Hello! I am Hirofumi Horiuchi. Corp: Job: IoT Engineer Hobby:
Camp, Watting Football @h_reader 2
“ Vue.js 3.x は現在 Beta版が リリースされています。 Vue.js 3.x is currently
in beta release.
“ Vue.js 3.x の Composition API を使ってみました I tried using
the Composition API of Vue.js 3.x
“ Composition API を利用すると VueComponent内のscriptの 書き方が変わります How to write script
in Vue Component changes when using Composition API.
“ 現在の書き方とComposition APIを 使った書き方で カウンターアプリを作ってみました I tried to make a
counter application with the current writing style and the writing style using Composition API.
7 カウンターアプリUI Counter app UI count up ボタン -> カウントを1上げる
count up button -> Add 1 to the count Count -> 現在のカウント Count -> Current count. Double -> カウントの2倍 Count -> Double the count.
現在の書き方 Current writing style
Composition APIの書き方 How to write with Composition API
“ なんだか面倒だな。。。 It's troublesome...
“ そんなふうに考えていた時期が 俺にもありました There was also a time when I
was thinking that way.
“ Composition APIおじさんは こう言っています。 He says:
“ Composition APIを使うと Component間のロジックを抽出して 簡単に再利用できるよ! The Composition APIs make it
more straightforward to extract and reuse logic between components.
“ 先ほどのロジックを 抽出してみましょう。 Let's extract the logic.
ロジックを抽出して別ファイルへ Extract logic to another file use_increment.js
ロジックを抽出して別ファイルへ Extract logic to another file component
“ なるほど!これはいいかも I got it! This might be good.
“ Vuexを使う場合はどうなるんだろう? What if I use Vuex?
Vuex を使う Use Vuex store
Vuex を使う Use Vuex component
Vuex を使うロジックを抽出 Extract the logic that uses Vuex use_increment_store.js
Vuex を使うロジックを抽出 Extract the logic that uses Vuex component
まとめ Summary Composition API は 機能ごとにComponentのロジックを分 割するためのAPI Composition API is
an API for dividing the component logic by function. 今まで複数のComponentで書いていた同じロジックをDRYに 書けそう I wrote the same logic to multiple components, but I can write to DRY. VSCode is the amazing editor.
おまけ extra 24
“ Composition API の公式に載っていた とても良かったコード Very good code on the
official Composition API site.
None
27 Thanks! Any questions? You can find me at ▪
@h_reader