Submit Search
Upload
Vue.jsコンポーネントのススメ
•
12 likes
•
6,989 views
takanori sugawara
Follow
vue component の意義を語ります!
Read less
Read more
Engineering
Slideshow view
Report
Share
Slideshow view
Report
Share
1 of 33
Download now
Download to read offline
Recommended
Underscore.jsの中のソースコードにみた John Resigさんと Jeremy Ashkenasさんの接点について
Underscore.jsの中のソースコードにみた John Resigさんと Jeremy Ashkenasさんの接点について
Makoto Hayase
Atomic Design デザインと実装の狭間
Atomic Design デザインと実装の狭間
takanori sugawara
2024 State of Marketing Report – by Hubspot
2024 State of Marketing Report – by Hubspot
Marius Sescu
Everything You Need To Know About ChatGPT
Everything You Need To Know About ChatGPT
Expeed Software
Product Design Trends in 2024 | Teenage Engineerings
Product Design Trends in 2024 | Teenage Engineerings
Pixeldarts
How Race, Age and Gender Shape Attitudes Towards Mental Health
How Race, Age and Gender Shape Attitudes Towards Mental Health
ThinkNow
AI Trends in Creative Operations 2024 by Artwork Flow.pdf
AI Trends in Creative Operations 2024 by Artwork Flow.pdf
marketingartwork
Skeleton Culture Code
Skeleton Culture Code
Skeleton Technologies
Recommended
Underscore.jsの中のソースコードにみた John Resigさんと Jeremy Ashkenasさんの接点について
Underscore.jsの中のソースコードにみた John Resigさんと Jeremy Ashkenasさんの接点について
Makoto Hayase
Atomic Design デザインと実装の狭間
Atomic Design デザインと実装の狭間
takanori sugawara
2024 State of Marketing Report – by Hubspot
2024 State of Marketing Report – by Hubspot
Marius Sescu
Everything You Need To Know About ChatGPT
Everything You Need To Know About ChatGPT
Expeed Software
Product Design Trends in 2024 | Teenage Engineerings
Product Design Trends in 2024 | Teenage Engineerings
Pixeldarts
How Race, Age and Gender Shape Attitudes Towards Mental Health
How Race, Age and Gender Shape Attitudes Towards Mental Health
ThinkNow
AI Trends in Creative Operations 2024 by Artwork Flow.pdf
AI Trends in Creative Operations 2024 by Artwork Flow.pdf
marketingartwork
Skeleton Culture Code
Skeleton Culture Code
Skeleton Technologies
PEPSICO Presentation to CAGNY Conference Feb 2024
PEPSICO Presentation to CAGNY Conference Feb 2024
Neil Kimberley
Content Methodology: A Best Practices Report (Webinar)
Content Methodology: A Best Practices Report (Webinar)
contently
How to Prepare For a Successful Job Search for 2024
How to Prepare For a Successful Job Search for 2024
Albert Qian
Social Media Marketing Trends 2024 // The Global Indie Insights
Social Media Marketing Trends 2024 // The Global Indie Insights
Kurio // The Social Media Age(ncy)
Trends In Paid Search: Navigating The Digital Landscape In 2024
Trends In Paid Search: Navigating The Digital Landscape In 2024
Search Engine Journal
5 Public speaking tips from TED - Visualized summary
5 Public speaking tips from TED - Visualized summary
SpeakerHub
ChatGPT and the Future of Work - Clark Boyd
ChatGPT and the Future of Work - Clark Boyd
Clark Boyd
Getting into the tech field. what next
Getting into the tech field. what next
Tessa Mero
Google's Just Not That Into You: Understanding Core Updates & Search Intent
Google's Just Not That Into You: Understanding Core Updates & Search Intent
Lily Ray
How to have difficult conversations
How to have difficult conversations
Rajiv Jayarajah, MAppComm, ACC
Introduction to Data Science
Introduction to Data Science
Christy Abraham Joy
Time Management & Productivity - Best Practices
Time Management & Productivity - Best Practices
Vit Horky
The six step guide to practical project management
The six step guide to practical project management
MindGenius
Beginners Guide to TikTok for Search - Rachel Pearson - We are Tilt __ Bright...
Beginners Guide to TikTok for Search - Rachel Pearson - We are Tilt __ Bright...
RachelPearson36
Unlocking the Power of ChatGPT and AI in Testing - A Real-World Look, present...
Unlocking the Power of ChatGPT and AI in Testing - A Real-World Look, present...
Applitools
12 Ways to Increase Your Influence at Work
12 Ways to Increase Your Influence at Work
GetSmarter
ChatGPT webinar slides
ChatGPT webinar slides
Alireza Esmikhani
More than Just Lines on a Map: Best Practices for U.S Bike Routes
More than Just Lines on a Map: Best Practices for U.S Bike Routes
Project for Public Spaces & National Center for Biking and Walking
Ride the Storm: Navigating Through Unstable Periods / Katerina Rudko (Belka G...
Ride the Storm: Navigating Through Unstable Periods / Katerina Rudko (Belka G...
DevGAMM Conference
Barbie - Brand Strategy Presentation
Barbie - Brand Strategy Presentation
Erica Santiago
More Related Content
Featured
PEPSICO Presentation to CAGNY Conference Feb 2024
PEPSICO Presentation to CAGNY Conference Feb 2024
Neil Kimberley
Content Methodology: A Best Practices Report (Webinar)
Content Methodology: A Best Practices Report (Webinar)
contently
How to Prepare For a Successful Job Search for 2024
How to Prepare For a Successful Job Search for 2024
Albert Qian
Social Media Marketing Trends 2024 // The Global Indie Insights
Social Media Marketing Trends 2024 // The Global Indie Insights
Kurio // The Social Media Age(ncy)
Trends In Paid Search: Navigating The Digital Landscape In 2024
Trends In Paid Search: Navigating The Digital Landscape In 2024
Search Engine Journal
5 Public speaking tips from TED - Visualized summary
5 Public speaking tips from TED - Visualized summary
SpeakerHub
ChatGPT and the Future of Work - Clark Boyd
ChatGPT and the Future of Work - Clark Boyd
Clark Boyd
Getting into the tech field. what next
Getting into the tech field. what next
Tessa Mero
Google's Just Not That Into You: Understanding Core Updates & Search Intent
Google's Just Not That Into You: Understanding Core Updates & Search Intent
Lily Ray
How to have difficult conversations
How to have difficult conversations
Rajiv Jayarajah, MAppComm, ACC
Introduction to Data Science
Introduction to Data Science
Christy Abraham Joy
Time Management & Productivity - Best Practices
Time Management & Productivity - Best Practices
Vit Horky
The six step guide to practical project management
The six step guide to practical project management
MindGenius
Beginners Guide to TikTok for Search - Rachel Pearson - We are Tilt __ Bright...
Beginners Guide to TikTok for Search - Rachel Pearson - We are Tilt __ Bright...
RachelPearson36
Unlocking the Power of ChatGPT and AI in Testing - A Real-World Look, present...
Unlocking the Power of ChatGPT and AI in Testing - A Real-World Look, present...
Applitools
12 Ways to Increase Your Influence at Work
12 Ways to Increase Your Influence at Work
GetSmarter
ChatGPT webinar slides
ChatGPT webinar slides
Alireza Esmikhani
More than Just Lines on a Map: Best Practices for U.S Bike Routes
More than Just Lines on a Map: Best Practices for U.S Bike Routes
Project for Public Spaces & National Center for Biking and Walking
Ride the Storm: Navigating Through Unstable Periods / Katerina Rudko (Belka G...
Ride the Storm: Navigating Through Unstable Periods / Katerina Rudko (Belka G...
DevGAMM Conference
Barbie - Brand Strategy Presentation
Barbie - Brand Strategy Presentation
Erica Santiago
Featured
(20)
PEPSICO Presentation to CAGNY Conference Feb 2024
PEPSICO Presentation to CAGNY Conference Feb 2024
Content Methodology: A Best Practices Report (Webinar)
Content Methodology: A Best Practices Report (Webinar)
How to Prepare For a Successful Job Search for 2024
How to Prepare For a Successful Job Search for 2024
Social Media Marketing Trends 2024 // The Global Indie Insights
Social Media Marketing Trends 2024 // The Global Indie Insights
Trends In Paid Search: Navigating The Digital Landscape In 2024
Trends In Paid Search: Navigating The Digital Landscape In 2024
5 Public speaking tips from TED - Visualized summary
5 Public speaking tips from TED - Visualized summary
ChatGPT and the Future of Work - Clark Boyd
ChatGPT and the Future of Work - Clark Boyd
Getting into the tech field. what next
Getting into the tech field. what next
Google's Just Not That Into You: Understanding Core Updates & Search Intent
Google's Just Not That Into You: Understanding Core Updates & Search Intent
How to have difficult conversations
How to have difficult conversations
Introduction to Data Science
Introduction to Data Science
Time Management & Productivity - Best Practices
Time Management & Productivity - Best Practices
The six step guide to practical project management
The six step guide to practical project management
Beginners Guide to TikTok for Search - Rachel Pearson - We are Tilt __ Bright...
Beginners Guide to TikTok for Search - Rachel Pearson - We are Tilt __ Bright...
Unlocking the Power of ChatGPT and AI in Testing - A Real-World Look, present...
Unlocking the Power of ChatGPT and AI in Testing - A Real-World Look, present...
12 Ways to Increase Your Influence at Work
12 Ways to Increase Your Influence at Work
ChatGPT webinar slides
ChatGPT webinar slides
More than Just Lines on a Map: Best Practices for U.S Bike Routes
More than Just Lines on a Map: Best Practices for U.S Bike Routes
Ride the Storm: Navigating Through Unstable Periods / Katerina Rudko (Belka G...
Ride the Storm: Navigating Through Unstable Periods / Katerina Rudko (Belka G...
Barbie - Brand Strategy Presentation
Barbie - Brand Strategy Presentation
Vue.jsコンポーネントのススメ
1.
vue.jsコンポーネント のススメ 菅原孝則 アソビュー株式会社
2.
菅原孝則 19歳の時からフリーでFlasherを始めてから かれこれ15年目になります。 今は、アソビュー株式会社という会社で デザイン・フロントエンド・バックエンドをやってます。
3.
jqueryとか使う従来の開発だと このコンポーネントの スタイルどこで書いてるか探 すの面倒くさい問題が勃発!
4.
つか、コンポーネントの修正す るのにcss,html,jsそれぞれファイ ル探すのダルイ。
5.
この場合の構造を 図示してみる (qiitaで以前誰かが書いてました)
6.
cssファイル スライダーコンポー ネントのスタイル カレンダーコンポー ネントのスタイル jsファイル スライダーコンポー ネントのロジック カレンダーコンポー ネントのコンポーネ ントのロジック htmlファイル スライダーコンポー ネントの構造 カレンダーコンポー ネントの構造 割と一般的なフロントエンドの水平構造
7.
まぁ、普通に、 css/js/htmlに分けて 作るよね
8.
でもさ、 js/calendar.js sass/calendar.sass いろんな.html 探すのダルくね?
9.
そこで、vue.js コン ポーネントの出番です。
10.
スライダーコンポーネント.vue カレンダーコンポーネント.vue スタイル スタイル ロジック
ロジック テンプレート テンプレート VUEコンポーネントの垂直統合
11.
いまいちピンとこない 大丈夫!
12.
<style scoped> :scope { min-height:
80px; height: 100%; width: 100%; display: table; position: relative; background-repeat: no-repeat; background-size : cover; background-position: center center; } …… </style> <template> <div class="fit-image" :style="innerStyle"> <div class="content" :class="valign"> <slot></slot> </div> </div> </template> <script type="text/ecmascript-6" lang="babel"> export default { props :["src", "valign"], computed : { innerStyle : function(){ return { "background-image" : 'url(' + this.s } } } } </script> これ!
13.
<body> <fit-image src="画像パス" >caption</fit-image> </body> <script
src=“vue.min.js”></script> <script src=“content.js”></script> したらコレで配置
14.
つまり
15.
クソコードが 1ファイルに!
16.
クソの局所化が できる!
17.
でもreact,polymerでも できるんじゃね?
18.
できる!
19.
でもさ IE9 SEO は大丈夫?
20.
あんまり大丈夫じゃない reactでも サーバーサイドでreactゴニョゴニョするか HTML-SNAPSHOTとかやれば何とかなりそうに思える。 polymerはそもそもIE9無理
21.
でも、いろいろあって うちの会社じゃ、 許してくれない!
22.
どうするか
23.
そんな時には、 vue.jsコンポーネント
24.
<body> <fit-image src="画像パス" >caption</fit-image> </body> <script
src=“vue.min.js”></script> <script src=“content.js”></script> ココに注目
25.
<template> <div class="fit-image" :style="innerStyle"> <div
class="content" :class="valign"> <slot></slot> </div> </div> </template> ココに差し込まれるのです!
26.
<body> <div class="fit-image"> <div class="content"
> caption </div> </div> </body> <script src=“vue.min.js”></script> <script src=“content.js”></script> jsでパースされると こうなる
27.
というわけこんなん もできる
28.
<body> <fit-image src="画像パス" > <h1>見出し</h1> </fit-image> </body> <script
src=“vue.min.js”></script> <script src=“content.js”></script> これでSEOも、 インタラクションもバッチリ!
29.
おめでとう! これで君もVUEコン ポーネント使いだ!
30.
最後に
31.
この手ものは、コン ポーネントがいっぱ い出てくるとはやっ てる感が出くるので
32.
reactじゃなくて、 vue.jsでコンポーネ ント書いたらシェア しよう!
33.
THANKS https://ts020.github.io/vue-loader-example/index.html サンプルはこちら
Download now