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
Nuxt Composition API 使ってみた
Search
Sponsored
·
SiteGround - Reliable hosting with speed, security, and support you can count on.
→
y-tsuzaki
September 17, 2021
Programming
300
0
Share
Embed
Copy iframe code
Copy JS code
Copy link
Start on current slide
Nuxt Composition API 使ってみた
y-tsuzaki
September 17, 2021
More Decks by y-tsuzaki
See All by y-tsuzaki
PHPカンファレンス福岡2024 【超特急】SQLアンチパターン総おさらいLT
ytsuzaki
1
1.7k
PHPカンファレンス北海道2024 リーダブルSQL
ytsuzaki
5
860
ある日PHPerがベンチャー企業のデータ基盤を作ることになったら
ytsuzaki
1
470
【PhpStorm】モブプログラミングの実践と学び【結局はバランス?】
ytsuzaki
0
560
PHPerKaigi 2022 【Laravel】 サクッとN + 1問題を見つけて倒しチャオ!
ytsuzaki
1
3.3k
【超特急】「SQLアンチパターン」 総おさらいLT 【4分で25個】
ytsuzaki
2
920
Nuxt.js x Composition API x TypeScript
ytsuzaki
0
830
PHPerKaigi 2021 LT PHPで簡単コード生成! 同じようなコードをたくさん書くなら コード生成しチャイナ!
ytsuzaki
0
180
アクセス制御ライブラリ Casbinを使ってみた
ytsuzaki
2
1.8k
Other Decks in Programming
See All in Programming
Augmenting AI with the Power of Jakarta EE
ivargrimstad
0
280
技術的負債を組織課題として解く-増えすぎたマイクロサービスとの戦い-
reimaru
1
2.2k
速く作れる。その次は、速く確かめられる開発へ 〜AIネイティブ開発を支える、Shift Down〜 / Can build fast. Next, moving to development where we can verify fast.
rkaga
5
4.1k
大喜利で理解するLLM as a Judge / Understanding LLM-as-a-Judge through Ogiri
rockname
0
160
モデルのリファクタリングが難しいと思ったら、そもそも複雑だったのはビジネス仕様だった ? / is-the-business-domain-the-real-complexity
hatsu38
0
390
AI活用は、個人から組織へ|マルチプレイヤーエージェントハーネス「QM」の社内活用事例 / AI use is moving from individuals to orgs
rkaga
1
140
TiDB Cloudのカスタムコントローラーによるオートスケール対応
takaidohigasi
0
130
テストを司るデーモンに会いに行く 〜隔離した仮想マシンでテストを通すまで〜
h1d3mun3
1
560
更なる可用性を求めて、5年間運用したKotlinのアプリケーションをGoでリプレイスする話
ken_tunc
0
340
Java 27新機能 / Java 27 new features
kishida
2
160
Webの地図
yosuke_furukawa
PRO
6
4.7k
Verilogで学ぶCPU自作入門.pdf
uyuki234
2
780
Featured
See All Featured
Writing Fast Ruby
sferik
630
63k
The AI Revolution Will Not Be Monopolized: How open-source beats economies of scale, even for LLMs
inesmontani
PRO
3
3.7k
Building a A Zero-Code AI SEO Workflow
portentint
PRO
0
730
Reality Check: Gamification 10 Years Later
codingconduct
0
2.3k
Color Theory Basics | Prateek | Gurzu
gurzu
1
470
Optimising Largest Contentful Paint
csswizardry
37
4k
Designing Powerful Visuals for Engaging Learning
tmiket
1
570
The Organizational Zoo: Understanding Human Behavior Agility Through Metaphoric Constructive Conversations (based on the works of Arthur Shelley, Ph.D)
kimpetersen
PRO
0
460
Connecting the Dots Between Site Speed, User Experience & Your Business [WebExpo 2025]
tammyeverts
11
1k
Let's Do A Bunch of Simple Stuff to Make Websites Faster
chriscoyier
508
140k
Ruling the World: When Life Gets Gamed
codingconduct
0
350
How to Talk to Developers About Accessibility
jct
2
550
Transcript
Nuxt Composition API 使ってみた 2021年9月17日 v-okinawa 株式会社 M&Aクラウド 津崎 善昭
自己紹介 津崎 善昭(つざき よしあき) Twitter: @820zacky 趣味:たまにキャンプ、たまに筋トレ(サボり中) 得意: 資格勉強 セキュリティスペシャリスト,ネットワークスペシャリスト,データベーススペシャリスト
SIer -> Web制作会社 -> Webベンチャー フロントエンド入門中
None
None
None
※ 北海道出身だけどいじめないでください
None
Composition API とは? Vue.jsのコンポーネントをいい感じに書く手法 2020年9月にリリースされたVue 3にて導入された 標準の書き方はOptions APIという コンポーネントからロジックを分離し、再利用可能にする 大規模・複雑なコンポーネントを作る時に便利
Nuxt.jsでComposition APIを使う2つのやり方 @vue/composition-api と @nuxtjs/comopsition-api
ふたつのやり方と言ったな? あれは嘘だ -> Nuxt3が10/12にリリースになりました https://nuxtjs.org/ja/v3/ もうどちらもいらない!
None
None
最初から入ってる
@vue/composition-api 従来のやり方 Vueの純正composition-api M&Aクラウドが使っているのはこれ SSRとCSRで値をハイドレーションできない問題があり困った (https://speakerdeck.com/kubotak/nuxt-dot-jsdecompositionapiwoshi-u? slide=16) 弊社ではVuexストアを使って値を共有している
@nuxtjs/comopsition-api = Nuxt Composition API 新しいやり方 nuxt-communityが提供している Nuxt 3 のための実験的なもの
Nuxt 3 ではメソッド名がかわるかもしれない Nuxt固有の機能を使える 弊社もこちらへの意向を検討中
Nuxt Composition API @vue/composition-apiの機能に加えてNuxt固有の機能を提供している useMeta : Metaタグの情報にアクセスするメソッド useAsync : NuxtのAsyncDataフックを使うメソッド
useFetch : NuxtのFetchフックを使うメソッド など reqRef, reqSsrRef, ssrRefなど新しい概念も登場している (まだよくわかってないがSSRとCSRで値を共有する方法っぽい)
なぜComposition APIなのか
処理をまとめられる
(無理矢理拡大した図) data()内にいろんな関心事の変数が定義されている
関心事ごとに変数を用意できる
ロジックを抽出して再利用 ref, reactiveなどのリアクティブな値を作成するメソッドや、onMountedなどのコ ールバック登録するメソッドなど、細かく機能が分割されているため、共通化した いロジックや肥大化したロジックを別ファイルに移することができる。 Options APIではMixinというTrait的なやり方でしか分離できず、再利用性が悪かっ た
Nuxt Composition APIの開発環境を作る
Nuxtインストール yarn create nuxt-app sample-app 言語はTypeScriptを選択する Composition APIを導入する yarn add
@nuxtjs/composition-api 今回は新しいやりかたである@nuxtjs/composition-apiを試してみる
nuxt.config.jsを編集する { buildModules: [ '@nuxt/typescript-build', + '@nuxtjs/composition-api/module' ] }
サーバーを起動する yarn dev localhost:3000でサイトが起動する
サンプルコード https://qiita.com/zackey2/items/8a2675c14d73e91267fe
まとめ Nuxt3 10/12リリース予定 Nuxt3 では最初から Composition APIが使えます!