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
VueでCSSモジュールを使った感想
Search
Sponsored
·
Ship Features Fearlessly
Turn features on and off without deploys. Used by thousands of Ruby developers.
→
Yasushi Asahi
May 14, 2019
Programming
710
1
Share
Embed
Copy iframe code
Copy JS code
Copy link
Start on current slide
VueでCSSモジュールを使った感想
Yasushi Asahi
May 14, 2019
More Decks by Yasushi Asahi
See All by Yasushi Asahi
フロントエンジニアでも GKEの開発環境を作りたいっ!!
yasushiasahi
0
490
Other Decks in Programming
See All in Programming
AIエージェントの隔離技術の徹底比較
kawayu
0
470
The Arts and Crafts of Work in the AI Era — Toward Mastery in Software Development
kuranuki
1
740
さぁV100、メモリをお食べ・・・
nilpe
0
130
ふつうのFeature Flag実践入門
irof
7
3.7k
セキュリティの専門家じゃなくてもできる。「セキュリティ意識」をアップデートして サプライチェーン攻撃への耐性を高めよう。
tk3fftk
5
690
OSもどきOS
arkw
0
470
ローカルLLMを使ってB2Bサービスを作っていての学び
yaotti
0
150
Dataformのリポジトリを立ち上げるときにまずやること / dataform-day0-2026
snhryt
0
130
AI 時代のソフトウェア設計の学び方
masuda220
PRO
29
12k
jQueryをバージョンアップする前に使いたいjQuery Migrate
matsuo_atsushi
0
200
キャリア迷子上等 ─ "ない道"は自分で作ればいい
16bitidol
3
1.9k
Modding RubyKaigi for Myself
yui_knk
0
910
Featured
See All Featured
Evolving SEO for Evolving Search Engines
ryanjones
0
210
Git: the NoSQL Database
bkeepers
PRO
432
67k
Design of three-dimensional binary manipulators for pick-and-place task avoiding obstacles (IECON2024)
konakalab
0
450
Templates, Plugins, & Blocks: Oh My! Creating the theme that thinks of everything
marktimemedia
31
2.8k
AI Search: Where Are We & What Can We Do About It?
aleyda
0
7.6k
Raft: Consensus for Rubyists
vanstee
141
7.5k
Conquering PDFs: document understanding beyond plain text
inesmontani
PRO
4
2.8k
The Success of Rails: Ensuring Growth for the Next 100 Years
eileencodes
47
8.2k
Jamie Indigo - Trashchat’s Guide to Black Boxes: Technical SEO Tactics for LLMs
techseoconnect
PRO
0
160
The Impact of AI in SEO - AI Overviews June 2024 Edition
aleyda
5
1.1k
Distributed Sagas: A Protocol for Coordinating Microservices
caitiem20
333
22k
SEO in 2025: How to Prepare for the Future of Search
ipullrank
3
3.5k
Transcript
プロジェクトで CSSモジュールを 使った感想
自己紹介 名前 zero 本名:旭康史(あさひやすし) 所属 カラビナテクノロジー 仕事 フロントエンド 技術 React好き(vueも好き)。Docker好き。Golang好き。 他 今期の覇権は「ひとりぼっちの◦◦生活」
ScopedParent.vue ScopedChild.vue <template> <div class="wrapper"> <h2>スコープドチャイルド</h2> </div> </template> <style scoped>
.wrapper { background-color: lime; } </style> <template> <div class="wrapper"> <h2>スコープドペアレント</h2> <ScopedChild /> </div> </template> <style scoped> .wrapper { padding: 20px; background-color: lightcyan; } </style> <div data-v-4f362c8a class="wrapper"> <h2 data-v-4f362c8a>スコープドペアレント</h2> <div data-v-0dcdfa6c data-v-4f362c8a class="wrapper"> <h2 data-v-0dcdfa6c>スコープドチャイルド</h2> </div> </div> scopedは 普通に 競合する
ModuleParent.vue ModuleChild.vue <template> <div :class="$style.wrapper"> <h2>モジュールチャイルド</h2> </div> </template> <style module>
.wrapper { background-color: lime; } </style> <template> <div :class="$style.wrapper"> <h2>モジュールペアレント</h2> <ModuleChild /> </div> </template> <style module> .wrapper { padding: 20px; background-color: lightcyan; } </style> moduleは いくぶん 安心 <div class="ModuleParent_wrapper_1qsYl"> <h2>モジュールペアレント</h2> <div class="ModuleChild_wrapper_1XBnr"> <h2>モジュールチャイルド</h2> </div> </div>
親で定義した スタイルを 子に渡せる
<template> <div :class="$style.wrapper"> <p>親</p> <div :class="$style.container"> <FirstChild :pStyle="$style" /> <SecondChild
:pStyle="$style" /> </div> </div> </template> <style module> .wrapper { padding: 10px; text-align: center; border: 1px solid indigo; } .container { display: flex; justify-content: space-around; } /* 子供用のスタイル */ .box { padding: 10px; background-color: lightgreen; } .text { text-decoration: underline; } </style> <template> <div :class="pStyle.box"> <h1 :class="pStyle.text">長男</h1> </div> </template> <template> <div :class="pStyle.box"> <h2 :class="pStyle.text">次男</h2> </div> </template> Parent.vue FirstChild.vue SecondChild.vue
moduleの嫌な所 ・いちいち $style って 書くのがめんどくさい ・クラス名がやたらと長くなって見づらい ・バインドし忘れる(:を付け忘れる) ・webpackの設定によっては 外部ライブラリのcssが崩れる。 ぶっちゃけデメリットのほうが大きい
scopedの欠点は工夫次第でどうとでも出来る!!
ありがとうございました またVueのプロジェクトや るとしたらscopedで書きま す (´・ω・`)