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
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
SREの積み重ねがAI駆動開発のガードレールになった ― 7つの実践/SRE Guardrails The 7
tomoyakitaura
8
4k
Contextとはなにか
chiroruxx
1
390
Prismを使った型安全な暗号化_関数型まつり2026
_fhhmm
0
110
気圧・高度・GPSを記録&可視化するアプリ「Koudo」を作った話
hjmkth
1
350
コンテキストの使い捨てをやめる — ビジネスルール駆動開発と miko —
ioki
0
270
フィードバックで育てるAI開発
kotaminato
1
110
JAWS-UG横浜 #102 AWSサ終供養LT会 成仏できない AWS サービスたち 〜本日、三体供養します〜
maroon1st
0
120
過去最大のMCPアップデート! 2026-07-28 RC版の謎に迫る
licux
6
460
SREは、MCPとSRE Agentをこう使え!
kazumax55
0
150
LaravelLive Japan の裏方のすべて — 第188回 PHP勉強会@東京 (2026-06-24)
suguruooki
2
150
1年で人数1.5倍、PR数5.5倍増。 品質とアウトカムはどうなったか、 何が効いたか
ike002jp
0
120
どこまでゆるくて許されるのか
tk3fftk
0
480
Featured
See All Featured
Mobile First: as difficult as doing things right
swwweet
225
10k
ラッコキーワード サービス紹介資料
rakko
1
3.9M
Understanding Cognitive Biases in Performance Measurement
bluesmoon
32
3k
We Are The Robots
honzajavorek
0
280
4 Signs Your Business is Dying
shpigford
187
22k
Into the Great Unknown - MozCon
thekraken
41
2.6k
[RailsConf 2023 Opening Keynote] The Magic of Rails
eileencodes
31
10k
Docker and Python
trallard
47
3.9k
Designing Powerful Visuals for Engaging Learning
tmiket
1
450
Music & Morning Musume
bryan
47
7.3k
Joys of Absence: A Defence of Solitary Play
codingconduct
1
410
Templates, Plugins, & Blocks: Oh My! Creating the theme that thinks of everything
marktimemedia
31
2.8k
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で書きま す (´・ω・`)