SlideShare a Scribd company logo
1 of 64
Introduction to modern front-end
with Vue.js
Ivan Nikulin
Monterail Academy, Nov. 2017
<html>
<head>
</head>
<body>
<h1>Hello world!</h1>
</body>
</html>
Hello world!
index.html
Hello Vue world!
index.vue
<template>
<h1>Hello Vue world!</h1>
</template>
terminal
npm install -g vue-cli@2.8.0
vue build index.vue
Hello Vue world!
index.vue
<template>
<h1>Hello Vue world!</h1>
</template>
<style>
h1 {
font-family: "Helvetica";
color: #1a94da;
}
</style>
Hello Vue.js world!
index.vue
<template>
<h1>Hello {{ title }} world!</h1>
</template>
<style>
h1 {
font-family: "Helvetica";
color: #1a94da;
}
</style>
...
<script>
export default {
data () {
return {
title: 'Vue.js'
}
}
}
</script>
Hello Vue.js world!
index.vue
<template>
<h1>Hello {{ title }} world!</h1>
</template>
<style>
h1 {
font-family: "Helvetica";
color: #1a94da;
}
</style>
...
<script>
export default {
data () {
return {
title: 'Vue.js'
}
}
}
</script>
Hello wild world!
index.vue
<template>
<h1>Hello {{ title }} world!</h1>
</template>
<style>
h1 {
font-family: "Helvetica";
color: #1a94da;
}
</style>
...
<script>
export default {
data () {
return {
title: 'wild'
}
}
}
</script>
Hello maths world!
index.vue
<template>
<div>
<h1>Hello {{ title }} world!</h1>
<pre>{{ a }} + {{ b }} = {{ a + b }}</pre>
</div>
</template>
<style>
h1 {
font-family: "Helvetica";
color: #1a94da;
}
</style>
...
<script>
export default {
data () {
return {
title: 'math',
a: 2,
b: 3
}
}
}
</script>
Hello maths world!
index.vue
<template>
<div>
<h1>Hello {{ title }} world!</h1>
<pre :title="description">
{{ a }} + {{ b }} = {{ a + b }}
</pre>
</div>
</template>
<style>
h1 {
font-family: "Helvetica";
color: #1a94da;
}
</style>
...
<script>
export default {
data () {
return {
title: 'math',
a: 2,
b: 3,
description: 'formula'
}
}
}
</script>
HTML elements vs components
HTML elements vs components
Let’s become a Vue.js developer!
index.vue
<template>
<div>
<h1>
Click below to become a Vue.js developer.
</h1>
<button>
Become a Vue.js developer
</button>
</div>
</template>
...
<style>
h1 {
font-family: "Helvetica";
color: #41b883;
}
</style>
Let’s become a Vue.js developer!
index.vue
<template>
<div>
<h1>
Congratulations, you’re a Vue.js developer!
</h1>
<h1>
Click below to become a Vue.js developer.
</h1>
<button>
Become a Vue.js developer
</button>
</div>
</template>
...
<style>
h1 {
font-family: "Helvetica";
color: #41b883;
}
</style>
Let’s become a Vue.js developer!
index.vue
<template>
<div>
<h1>
Congratulations, you are a Vue.js developer!
</h1>
<h1>
Click below to become a Vue.js developer.
</h1>
<button>
Become a Vue.js developer
</button>
</div>
</template>
<script>
export default {
data () {
return {
isVueDeveloper: false
}
}
}
</script>
Let’s become a Vue.js developer!
index.vue
<template>
<div>
<h1 v-if="isVueDeveloper">
Congratulations, you are a Vue.js developer!
</h1>
<h1>
Click below to become a Vue.js developer.
</h1>
<button>
Become a Vue.js developer
</button>
</div>
</template>
<script>
export default {
data () {
return {
isVueDeveloper: false
}
}
}
</script>
isVueDeveloper: false isVueDeveloper: true
Let’s become a Vue.js developer!
index.vue
<template>
<div>
<h1 v-if="isVueDeveloper">
Congratulations, you are a Vue.js developer!
</h1>
<h1 v-if="!isVueDeveloper">
Click below to become a Vue.js developer.
</h1>
<button>
Become a Vue.js developer
</button>
</div>
</template>
<script>
export default {
data () {
return {
isVueDeveloper: false
}
}
}
</script>
isVueDeveloper: false isVueDeveloper: true
Let’s become a Vue.js developer!
index.vue
<template>
<div>
<h1 v-if="isVueDeveloper">
Congratulations, you are a Vue.js developer!
</h1>
<h1 v-if="!isVueDeveloper">
Click below to become a Vue.js developer.
</h1>
<button @click="isVueDeveloper = true">
Become a Vue.js developer
</button>
</div>
</template>
<script>
export default {
data () {
return {
isVueDeveloper: false
}
}
}
</script>
Let’s become a Vue.js developer!
index.vue
<template>
<div>
<h1 v-if="isVueDeveloper">
Congratulations, you are a Vue.js developer!
</h1>
<h1 v-else>
Click below to become a Vue.js developer.
</h1>
<button @click="isVueDeveloper = true">
Become a Vue.js developer
</button>
</div>
</template>
<script>
export default {
data () {
return {
isVueDeveloper: false
}
}
}
</script>
Let’s become a Vue.js developer!
index.vue
<template>
<div>
<h1 v-if="isVueDeveloper">
Congratulations, you are a Vue.js developer!
</h1>
<h1 v-else>
Click below to become a Vue.js developer.
</h1>
<button @click="becomeVueDeveloper">
Become a Vue.js developer
</button>
</div>
</template>
<script>
export default {
data () {
return {
isVueDeveloper: false
}
},
methods: {
becomeVueDeveloper () {
this.isVueDeveloper = true
}
}
}
</script>
What is ES6 anyway?
ES6
<script>
export default {
data () {
return {
isVueDeveloper: false
}
},
methods: {
becomeVueDeveloper () {
this.isVueDeveloper = true
}
}
}
</script>
ES5
<script>
module.exports = {
data: function () {
return {
isVueDeveloper: false
}
},
methods: {
becomeVueDeveloper: function () {
this.isVueDeveloper = true
}
}
}
</script>
Let’s become a better Vue.js developer!
index.vue
<template>
<div>
<h1>
Click 5 times to become a better Vue.js developer.
</h1>
<button>
Become a better Vue.js developer
</button>
</div>
</template>
...
<style>
h1 {
font-family: "Helvetica";
color: #41b883;
}
</style>
Let’s become a better Vue.js developer!
index.vue
<template>
<div>
<h1>
Click {{ clicksLeft }} times to become
a better Vue.js developer.
</h1>
<button>
Become a better Vue.js developer
</button>
</div>
</template>
...
<script>
export default {
data () {
return {
clicksLeft: 5
}
}
}
</script>
Let’s become a better Vue.js developer!
index.vue
<template>
<div>
<h1>
Click {{ clicksLeft }} times to become
a better Vue.js developer.
</h1>
<button @click="decrementClicks">
Become a better Vue.js developer
</button>
</div>
</template>
<script>
export default {
data () {
return {
clicksLeft: 5
}
},
methods: {
decrementClicks () {
this.clicksLeft -= 1
}
}
}
</script>
Let’s become a better Vue.js developer!
index.vue
<template>
<div>
<h1>
Click {{ clicksLeft }} times to become
a better Vue.js developer.
</h1>
<button @click="decrementClicks">
Become a better Vue.js developer
</button>
</div>
</template>
<script>
export default {
data () {
return {
clicksLeft: 5
}
},
methods: {
decrementClicks () {
if (this.clicksLeft > 0) {
this.clicksLeft -= 1
}
}
}
}
</script>
Let’s become a better Vue.js developer!
index.vue
<template>
<div>
<h1 v-if="clicksLeft === 0">
Congratulations, you are a better Vue.js developer!
</h1>
<h1 v-else>
Click {{ clicksLeft }} times to become
a better Vue.js developer.
</h1>
<button @click="decrementClicks">
Become a better Vue.js developer
</button>
</div>
</template>
<script>
export default {
data () {
return {
clicksLeft: 5
}
},
methods: {
decrementClicks () {
if (this.clicksLeft > 0) {
this.clicksLeft -= 1
}
}
}
}
</script>
Looks familiar…
Before
<template>
<div>
<h1 v-if="isVueDeveloper">
Congratulations, you are a Vue.js developer!
</h1>
<h1 v-else>
Click below to become a Vue.js developer.
</h1>
<button @click="becomeVueDeveloper">
Become a Vue.js developer
</button>
</div>
</template>
Now
<template>
<div>
<h1 v-if="clicksLeft === 0">
Congratulations, you are a better
Vue.js developer!
</h1>
<h1 v-else>
Click {{ clicksLeft }} times to become
a better Vue.js developer.
</h1>
<button @click="decrementClicks">
Become a better Vue.js developer
</button>
</div>
</template>
Let’s become a better Vue.js developer!
index.vue
<template>
<div>
<h1 v-if="isBetterVueDeveloper">
Congratulations, you are a better
Vue.js developer!
</h1>
<h1 v-else>
Click {{ clicksLeft }} times to become
a better Vue.js developer.
</h1>
<button @click="decrementClicks">
Become a better Vue.js developer
</button>
</div>
</template>
<script>
export default {
data () {
return {
clicksLeft: 5
}
},
computed: {
isBetterVueDeveloper () {
return this.clicksLeft === 0
}
},
methods: {
decrementClicks () {
if (this.clicksLeft > 0) {
this.clicksLeft -= 1
}
}
}
}
</script>
What vs How?
Declarative (yay!)
● what should be shown
● what data means
● what happens on interaction
Imperative (nay)
● how should be rendered
● how data is computed
● how to update after changes
WHAT HOW
Let’s become a super Vue.js developer!
index.vue
<template>
<div>
<h1>
Check all things below to become a super Vue.js developer 0/4
</h1>
<ul>
<li><input type="checkbox"> knows v-if &amp; v-else</li>
<li><input type="checkbox"> knows methods &amp; computed</li>
<li><input type="checkbox"> knows v-model</li>
<li><input type="checkbox"> knows v-for</li>
</ul>
</div>
</template>
<style>
h1 {
font-family: "Helvetica";
color: #41b883;
}
li {
list-style: none;
font-size: 30px;
}
input[type="checkbox"] {
width: 20px;
height: 20px;
}
</style>
Let’s become a super Vue.js developer!
index.vue
<template>
<div>
<h1>
Check all things below to become a super
Vue.js developer {{ checkedCount }}/4
</h1>
<ul>
<li>
<input type="checkbox" v-model="isChecked">
knows v-if &amp; v-else
</li>
</ul>
</div>
</template>
<script>
export default {
data () {
return {
isChecked: false
}
},
computed: {
checkedCount () {
if (this.isChecked) return 1
return 0
}
}
}
</script>
Let’s become a super Vue.js developer!
index.vue
<template>
<div>
<h1>
Check all things below to become a super Vue.js developer
{{ checkedCount }}/4
</h1>
<ul>
<li>
<input type="checkbox" v-model="isChecked1"> knows v-if &amp; v-else
</li>
<li>
<input type="checkbox" v-model="isChecked2"> knows methods &amp; computed
</li>
<li>
<input type="checkbox" v-model="isChecked3"> knows v-model
</li>
<li>
<input type="checkbox" v-model="isChecked4"> knows v-for
</li>
</ul>
</div>
</template>
<script>
export default {
data () {
return {
isChecked1: false,
isChecked2: false,
isChecked3: false,
isChecked4: false
}
},
computed: {
checkedCount () {
// A lot of ifs...
}
}
}
</script>
pls dont
DRY
Don’t Repeat Yourself
Let’s become a super Vue.js developer!
index.vue
<template>
<div>
<h1>
Check all things below to become a super
Vue.js developer {{ checkedCount }}/4
</h1>
<ul>
<li v-for="item in items">
<input type="checkbox" v-model="item.isChecked">
knows v-if &amp; v-else
</li>
</ul>
</div>
</template>
<script>
export default {
data () {
return {
items: [
{ isChecked: false },
{ isChecked: false },
{ isChecked: false },
{ isChecked: false }
]
}
},
computed: {
checkedCount () {
return 0 // TODO
}
}
}
</script>
Let’s become a super Vue.js developer!
index.vue
<template>
<div>
<h1>
Check all things below to become a super
Vue.js developer {{ checkedCount }}/4
</h1>
<ul>
<li v-for="item in items">
<input type="checkbox" v-model="item.isChecked">
{{ item.description }}
</li>
</ul>
</div>
</template>
<script>
export default {
data () {
return {
items: [
{ isChecked: false, description: 'knows v-if & v-else' },
{ isChecked: false, description: 'knows methods & computed' },
{ isChecked: false, description: 'knows v-model' },
{ isChecked: false, description: 'knows v-for' }
]
}
},
computed: {
checkedCount () {
return 0 // TODO
}
}
}
</script>
Let’s become a super Vue.js developer!
Imperative (how)
computed: {
checkedCount () {
let count = 0
for (const item of this.items) {
if (item.isChecked) {
count += 1
}
}
return count
}
}
Declarative (what)
computed: {
checkedCount () {
return this.items
.filter(item => item.isChecked)
.length
}
}
Let’s become a super Vue.js developer!
index.vue
<template>
<div>
<h1 v-if="isSuperVueDeveloper">
Congratulations, you are a super Vue.js developer!
</h1>
<template v-else>
<h1>
Check all things below to become a super Vue.js developer
{{ checkedCount }}/4
</h1>
<ul>
<li v-for="item in items">
<input type="checkbox" v-model="item.isChecked">
{{ item.description }}
</li>
</ul>
</template>
</div>
</template>
<script>
export default {
data () {
...
},
computed: {
checkedCount () {
return this.items
.filter(item => item.isChecked)
.length
},
isSuperVueDeveloper () {
return this.checkedCount === 4
}
}
}
</script>
different stuff
Let’s become a super Vue.js developer!
Magical numbers
computed: {
isSuperVueDeveloper () {
return this.checkedCount === 4
}
}
Declarative logic
computed: {
isSuperVueDeveloper () {
return this.checkedCount === this.items.length
}
}
Let’s become a super Vue.js developer!
index.vue
<template>
<div>
<h1 v-if="isSuperVueDeveloper">
Congratulations, you are a super Vue.js developer!
</h1>
<template v-else>
<h1>
Check all things below to become a super Vue.js developer
{{ checkedCount }}/{{ items.length }}
</h1>
<ul>
<li v-for="item in items" :key="item.description">
<input type="checkbox" v-model="item.isChecked">
{{ item.description }}
</li>
</ul>
</template>
</div>
</template>
All together now!!!
first-challenge.vue
<template>
<div>
<h1 v-if="isVueDeveloper">
Congratulations, you are a Vue.js developer!
...
second-challenge.vue
<template>
<div>
<h1 v-if="isBetterVueDeveloper">
Congratulations, you are a better Vue.js developer!
...
third-challenge.vue
<template>
<div>
<h1 v-if="isSuperVueDeveloper">
Congratulations, you are a super Vue.js developer!
...
<template>
<main>
<FirstChallenge />
<hr />
<SecondChallenge />
<hr />
<ThirdChallenge />
</main>
</template>
<script>
import FirstChallenge from './first-challenge'
import SecondChallenge from './second-challenge'
import ThirdChallenge from './third-challenge'
export default {
components: {
FirstChallenge,
SecondChallenge,
ThirdChallenge
}
}
</script>
index.vue
What we learned
Vue.js
● data binding
● v-if, v-else
● methods
● computed
● v-model
● v-for, :key
Front-end
● components
● declarative style
● DRY
What’s yet to learn
● communication between components
● routing
● scoped styles
● transitions
● dynamic styles
● Pug, SCSS/Sass/Stylus/PostCSS
● ... everything else!
Where to learn
https://vuejs.org/v2/guide/
Workshops

More Related Content

What's hot

What's hot (20)

Meet VueJs
Meet VueJsMeet VueJs
Meet VueJs
 
The Point of Vue - Intro to Vue.js
The Point of Vue - Intro to Vue.jsThe Point of Vue - Intro to Vue.js
The Point of Vue - Intro to Vue.js
 
VueJS Introduction
VueJS IntroductionVueJS Introduction
VueJS Introduction
 
Don't Over-React - just use Vue!
Don't Over-React - just use Vue!Don't Over-React - just use Vue!
Don't Over-React - just use Vue!
 
Building a Single Page Application with VueJS
Building a Single Page Application with VueJSBuilding a Single Page Application with VueJS
Building a Single Page Application with VueJS
 
An introduction to Vue.js
An introduction to Vue.jsAn introduction to Vue.js
An introduction to Vue.js
 
Web components
Web componentsWeb components
Web components
 
How to Build ToDo App with Vue 3 + TypeScript
How to Build ToDo App with Vue 3 + TypeScriptHow to Build ToDo App with Vue 3 + TypeScript
How to Build ToDo App with Vue 3 + TypeScript
 
Vue presentation
Vue presentationVue presentation
Vue presentation
 
WordPress 2017 with VueJS and GraphQL
WordPress 2017 with VueJS and GraphQLWordPress 2017 with VueJS and GraphQL
WordPress 2017 with VueJS and GraphQL
 
Intro to Vue
Intro to Vue Intro to Vue
Intro to Vue
 
Love at first Vue
Love at first VueLove at first Vue
Love at first Vue
 
Building a js widget
Building a js widgetBuilding a js widget
Building a js widget
 
Vue business first
Vue business firstVue business first
Vue business first
 
Nuxt.JS Introdruction
Nuxt.JS IntrodructionNuxt.JS Introdruction
Nuxt.JS Introdruction
 
Javascript MVVM with Vue.JS
Javascript MVVM with Vue.JSJavascript MVVM with Vue.JS
Javascript MVVM with Vue.JS
 
Real World Lessons in Progressive Web Application & Service Worker Caching
Real World Lessons in Progressive Web Application & Service Worker CachingReal World Lessons in Progressive Web Application & Service Worker Caching
Real World Lessons in Progressive Web Application & Service Worker Caching
 
introduction to Vue.js 3
introduction to Vue.js 3 introduction to Vue.js 3
introduction to Vue.js 3
 
The Complementarity of React and Web Components
The Complementarity of React and Web ComponentsThe Complementarity of React and Web Components
The Complementarity of React and Web Components
 
Micronaut For Single Page Apps
Micronaut For Single Page AppsMicronaut For Single Page Apps
Micronaut For Single Page Apps
 

Similar to Introduction to modern front-end with Vue.js

WordPress Admin UI - Future Proofing Your Admin Pages
WordPress Admin UI - Future Proofing Your Admin PagesWordPress Admin UI - Future Proofing Your Admin Pages
WordPress Admin UI - Future Proofing Your Admin Pages
Brandon Dove
 
Angular js quickstart
Angular js quickstartAngular js quickstart
Angular js quickstart
LinkMe Srl
 

Similar to Introduction to modern front-end with Vue.js (20)

Front End Development for Back End Developers - Denver Startup Week 2017
Front End Development for Back End Developers - Denver Startup Week 2017Front End Development for Back End Developers - Denver Startup Week 2017
Front End Development for Back End Developers - Denver Startup Week 2017
 
Learning Svelte
Learning SvelteLearning Svelte
Learning Svelte
 
Day of code
Day of codeDay of code
Day of code
 
Python Code Camp for Professionals 1/4
Python Code Camp for Professionals 1/4Python Code Camp for Professionals 1/4
Python Code Camp for Professionals 1/4
 
Stop reinventing the wheel: Build Responsive Websites Using Bootstrap
Stop reinventing the wheel: Build Responsive Websites Using BootstrapStop reinventing the wheel: Build Responsive Websites Using Bootstrap
Stop reinventing the wheel: Build Responsive Websites Using Bootstrap
 
Vue.js part1
Vue.js part1Vue.js part1
Vue.js part1
 
WordPress Admin UI - Future Proofing Your Admin Pages
WordPress Admin UI - Future Proofing Your Admin PagesWordPress Admin UI - Future Proofing Your Admin Pages
WordPress Admin UI - Future Proofing Your Admin Pages
 
Angular JS Introduction
Angular JS IntroductionAngular JS Introduction
Angular JS Introduction
 
Making WordPress Your CMS and Automatically Updating a Self Hosted WordPress ...
Making WordPress Your CMS and Automatically Updating a Self Hosted WordPress ...Making WordPress Your CMS and Automatically Updating a Self Hosted WordPress ...
Making WordPress Your CMS and Automatically Updating a Self Hosted WordPress ...
 
Refresh Austin - Intro to Dexy
Refresh Austin - Intro to DexyRefresh Austin - Intro to Dexy
Refresh Austin - Intro to Dexy
 
Introduction to AngularJS
Introduction to AngularJSIntroduction to AngularJS
Introduction to AngularJS
 
Angular js quickstart
Angular js quickstartAngular js quickstart
Angular js quickstart
 
HTML5, the new buzzword
HTML5, the new buzzwordHTML5, the new buzzword
HTML5, the new buzzword
 
Django crush course
Django crush course Django crush course
Django crush course
 
Agile Wordpress
Agile WordpressAgile Wordpress
Agile Wordpress
 
Sperimentazioni lezione6 from_designtoapplication copy
Sperimentazioni lezione6 from_designtoapplication copySperimentazioni lezione6 from_designtoapplication copy
Sperimentazioni lezione6 from_designtoapplication copy
 
Level up apps and websites with vue.js
Level up  apps and websites with vue.jsLevel up  apps and websites with vue.js
Level up apps and websites with vue.js
 
Level up apps and websites with vue.js
Level up  apps and websites with vue.jsLevel up  apps and websites with vue.js
Level up apps and websites with vue.js
 
An introduction to Vue.js
An introduction to Vue.jsAn introduction to Vue.js
An introduction to Vue.js
 
A (very) opinionated guide to MSBuild and Project Files
A (very) opinionated guide to MSBuild and Project FilesA (very) opinionated guide to MSBuild and Project Files
A (very) opinionated guide to MSBuild and Project Files
 

More from monterail

More from monterail (9)

MonteTalks #2 Sales & Marketing — Love or Hate Relationship?
MonteTalks #2 Sales & Marketing — Love or Hate Relationship? MonteTalks #2 Sales & Marketing — Love or Hate Relationship?
MonteTalks #2 Sales & Marketing — Love or Hate Relationship?
 
Emotional and Artificial Intelligence in Team Performance Software
Emotional and Artificial Intelligence in Team Performance SoftwareEmotional and Artificial Intelligence in Team Performance Software
Emotional and Artificial Intelligence in Team Performance Software
 
Marketing B2B at Monterail — Szymon Boniecki, co-founder
Marketing B2B at Monterail — Szymon Boniecki, co-founder Marketing B2B at Monterail — Szymon Boniecki, co-founder
Marketing B2B at Monterail — Szymon Boniecki, co-founder
 
Storytelling in data visualization — Head of Design, Monterail
Storytelling in data visualization — Head of Design, MonterailStorytelling in data visualization — Head of Design, Monterail
Storytelling in data visualization — Head of Design, Monterail
 
Girls in IT - QA
Girls in IT - QA Girls in IT - QA
Girls in IT - QA
 
Monterail Academy — Visual screen design dla początkujących
Monterail Academy — Visual screen design dla początkujących Monterail Academy — Visual screen design dla początkujących
Monterail Academy — Visual screen design dla początkujących
 
Girls in It - Front-end & Back-end. Jak zacząć
Girls in It - Front-end & Back-end. Jak zacząćGirls in It - Front-end & Back-end. Jak zacząć
Girls in It - Front-end & Back-end. Jak zacząć
 
Girls in IT - Projektantka UI/UX. Jak zacząć?
Girls in IT - Projektantka UI/UX. Jak zacząć?Girls in IT - Projektantka UI/UX. Jak zacząć?
Girls in IT - Projektantka UI/UX. Jak zacząć?
 
IoT Poland 2016 - Over the air deployment bringing business closer to agile
IoT Poland 2016 - Over the air deployment bringing business closer to agileIoT Poland 2016 - Over the air deployment bringing business closer to agile
IoT Poland 2016 - Over the air deployment bringing business closer to agile
 

Recently uploaded

+971581248768>> SAFE AND ORIGINAL ABORTION PILLS FOR SALE IN DUBAI AND ABUDHA...
+971581248768>> SAFE AND ORIGINAL ABORTION PILLS FOR SALE IN DUBAI AND ABUDHA...+971581248768>> SAFE AND ORIGINAL ABORTION PILLS FOR SALE IN DUBAI AND ABUDHA...
+971581248768>> SAFE AND ORIGINAL ABORTION PILLS FOR SALE IN DUBAI AND ABUDHA...
?#DUbAI#??##{{(☎️+971_581248768%)**%*]'#abortion pills for sale in dubai@
 
Histor y of HAM Radio presentation slide
Histor y of HAM Radio presentation slideHistor y of HAM Radio presentation slide
Histor y of HAM Radio presentation slide
vu2urc
 
Artificial Intelligence: Facts and Myths
Artificial Intelligence: Facts and MythsArtificial Intelligence: Facts and Myths
Artificial Intelligence: Facts and Myths
Joaquim Jorge
 

Recently uploaded (20)

🐬 The future of MySQL is Postgres 🐘
🐬  The future of MySQL is Postgres   🐘🐬  The future of MySQL is Postgres   🐘
🐬 The future of MySQL is Postgres 🐘
 
How to Troubleshoot Apps for the Modern Connected Worker
How to Troubleshoot Apps for the Modern Connected WorkerHow to Troubleshoot Apps for the Modern Connected Worker
How to Troubleshoot Apps for the Modern Connected Worker
 
[2024]Digital Global Overview Report 2024 Meltwater.pdf
[2024]Digital Global Overview Report 2024 Meltwater.pdf[2024]Digital Global Overview Report 2024 Meltwater.pdf
[2024]Digital Global Overview Report 2024 Meltwater.pdf
 
Apidays New York 2024 - Scaling API-first by Ian Reasor and Radu Cotescu, Adobe
Apidays New York 2024 - Scaling API-first by Ian Reasor and Radu Cotescu, AdobeApidays New York 2024 - Scaling API-first by Ian Reasor and Radu Cotescu, Adobe
Apidays New York 2024 - Scaling API-first by Ian Reasor and Radu Cotescu, Adobe
 
A Year of the Servo Reboot: Where Are We Now?
A Year of the Servo Reboot: Where Are We Now?A Year of the Servo Reboot: Where Are We Now?
A Year of the Servo Reboot: Where Are We Now?
 
+971581248768>> SAFE AND ORIGINAL ABORTION PILLS FOR SALE IN DUBAI AND ABUDHA...
+971581248768>> SAFE AND ORIGINAL ABORTION PILLS FOR SALE IN DUBAI AND ABUDHA...+971581248768>> SAFE AND ORIGINAL ABORTION PILLS FOR SALE IN DUBAI AND ABUDHA...
+971581248768>> SAFE AND ORIGINAL ABORTION PILLS FOR SALE IN DUBAI AND ABUDHA...
 
Workshop - Best of Both Worlds_ Combine KG and Vector search for enhanced R...
Workshop - Best of Both Worlds_ Combine  KG and Vector search for  enhanced R...Workshop - Best of Both Worlds_ Combine  KG and Vector search for  enhanced R...
Workshop - Best of Both Worlds_ Combine KG and Vector search for enhanced R...
 
Connector Corner: Accelerate revenue generation using UiPath API-centric busi...
Connector Corner: Accelerate revenue generation using UiPath API-centric busi...Connector Corner: Accelerate revenue generation using UiPath API-centric busi...
Connector Corner: Accelerate revenue generation using UiPath API-centric busi...
 
Driving Behavioral Change for Information Management through Data-Driven Gree...
Driving Behavioral Change for Information Management through Data-Driven Gree...Driving Behavioral Change for Information Management through Data-Driven Gree...
Driving Behavioral Change for Information Management through Data-Driven Gree...
 
What Are The Drone Anti-jamming Systems Technology?
What Are The Drone Anti-jamming Systems Technology?What Are The Drone Anti-jamming Systems Technology?
What Are The Drone Anti-jamming Systems Technology?
 
TrustArc Webinar - Unlock the Power of AI-Driven Data Discovery
TrustArc Webinar - Unlock the Power of AI-Driven Data DiscoveryTrustArc Webinar - Unlock the Power of AI-Driven Data Discovery
TrustArc Webinar - Unlock the Power of AI-Driven Data Discovery
 
Boost PC performance: How more available memory can improve productivity
Boost PC performance: How more available memory can improve productivityBoost PC performance: How more available memory can improve productivity
Boost PC performance: How more available memory can improve productivity
 
AWS Community Day CPH - Three problems of Terraform
AWS Community Day CPH - Three problems of TerraformAWS Community Day CPH - Three problems of Terraform
AWS Community Day CPH - Three problems of Terraform
 
Histor y of HAM Radio presentation slide
Histor y of HAM Radio presentation slideHistor y of HAM Radio presentation slide
Histor y of HAM Radio presentation slide
 
Boost Fertility New Invention Ups Success Rates.pdf
Boost Fertility New Invention Ups Success Rates.pdfBoost Fertility New Invention Ups Success Rates.pdf
Boost Fertility New Invention Ups Success Rates.pdf
 
Partners Life - Insurer Innovation Award 2024
Partners Life - Insurer Innovation Award 2024Partners Life - Insurer Innovation Award 2024
Partners Life - Insurer Innovation Award 2024
 
The 7 Things I Know About Cyber Security After 25 Years | April 2024
The 7 Things I Know About Cyber Security After 25 Years | April 2024The 7 Things I Know About Cyber Security After 25 Years | April 2024
The 7 Things I Know About Cyber Security After 25 Years | April 2024
 
Artificial Intelligence: Facts and Myths
Artificial Intelligence: Facts and MythsArtificial Intelligence: Facts and Myths
Artificial Intelligence: Facts and Myths
 
Real Time Object Detection Using Open CV
Real Time Object Detection Using Open CVReal Time Object Detection Using Open CV
Real Time Object Detection Using Open CV
 
Understanding Discord NSFW Servers A Guide for Responsible Users.pdf
Understanding Discord NSFW Servers A Guide for Responsible Users.pdfUnderstanding Discord NSFW Servers A Guide for Responsible Users.pdf
Understanding Discord NSFW Servers A Guide for Responsible Users.pdf
 

Introduction to modern front-end with Vue.js

  • 1. Introduction to modern front-end with Vue.js Ivan Nikulin Monterail Academy, Nov. 2017
  • 2.
  • 4.
  • 5. Hello Vue world! index.vue <template> <h1>Hello Vue world!</h1> </template> terminal npm install -g vue-cli@2.8.0 vue build index.vue
  • 6.
  • 7. Hello Vue world! index.vue <template> <h1>Hello Vue world!</h1> </template> <style> h1 { font-family: "Helvetica"; color: #1a94da; } </style>
  • 8.
  • 9. Hello Vue.js world! index.vue <template> <h1>Hello {{ title }} world!</h1> </template> <style> h1 { font-family: "Helvetica"; color: #1a94da; } </style> ... <script> export default { data () { return { title: 'Vue.js' } } } </script>
  • 10. Hello Vue.js world! index.vue <template> <h1>Hello {{ title }} world!</h1> </template> <style> h1 { font-family: "Helvetica"; color: #1a94da; } </style> ... <script> export default { data () { return { title: 'Vue.js' } } } </script>
  • 11.
  • 12. Hello wild world! index.vue <template> <h1>Hello {{ title }} world!</h1> </template> <style> h1 { font-family: "Helvetica"; color: #1a94da; } </style> ... <script> export default { data () { return { title: 'wild' } } } </script>
  • 13.
  • 14. Hello maths world! index.vue <template> <div> <h1>Hello {{ title }} world!</h1> <pre>{{ a }} + {{ b }} = {{ a + b }}</pre> </div> </template> <style> h1 { font-family: "Helvetica"; color: #1a94da; } </style> ... <script> export default { data () { return { title: 'math', a: 2, b: 3 } } } </script>
  • 15.
  • 16. Hello maths world! index.vue <template> <div> <h1>Hello {{ title }} world!</h1> <pre :title="description"> {{ a }} + {{ b }} = {{ a + b }} </pre> </div> </template> <style> h1 { font-family: "Helvetica"; color: #1a94da; } </style> ... <script> export default { data () { return { title: 'math', a: 2, b: 3, description: 'formula' } } } </script>
  • 17.
  • 18. HTML elements vs components
  • 19. HTML elements vs components
  • 20. Let’s become a Vue.js developer! index.vue <template> <div> <h1> Click below to become a Vue.js developer. </h1> <button> Become a Vue.js developer </button> </div> </template> ... <style> h1 { font-family: "Helvetica"; color: #41b883; } </style>
  • 21.
  • 22. Let’s become a Vue.js developer! index.vue <template> <div> <h1> Congratulations, you’re a Vue.js developer! </h1> <h1> Click below to become a Vue.js developer. </h1> <button> Become a Vue.js developer </button> </div> </template> ... <style> h1 { font-family: "Helvetica"; color: #41b883; } </style>
  • 23.
  • 24. Let’s become a Vue.js developer! index.vue <template> <div> <h1> Congratulations, you are a Vue.js developer! </h1> <h1> Click below to become a Vue.js developer. </h1> <button> Become a Vue.js developer </button> </div> </template> <script> export default { data () { return { isVueDeveloper: false } } } </script>
  • 25. Let’s become a Vue.js developer! index.vue <template> <div> <h1 v-if="isVueDeveloper"> Congratulations, you are a Vue.js developer! </h1> <h1> Click below to become a Vue.js developer. </h1> <button> Become a Vue.js developer </button> </div> </template> <script> export default { data () { return { isVueDeveloper: false } } } </script>
  • 27. Let’s become a Vue.js developer! index.vue <template> <div> <h1 v-if="isVueDeveloper"> Congratulations, you are a Vue.js developer! </h1> <h1 v-if="!isVueDeveloper"> Click below to become a Vue.js developer. </h1> <button> Become a Vue.js developer </button> </div> </template> <script> export default { data () { return { isVueDeveloper: false } } } </script>
  • 29. Let’s become a Vue.js developer! index.vue <template> <div> <h1 v-if="isVueDeveloper"> Congratulations, you are a Vue.js developer! </h1> <h1 v-if="!isVueDeveloper"> Click below to become a Vue.js developer. </h1> <button @click="isVueDeveloper = true"> Become a Vue.js developer </button> </div> </template> <script> export default { data () { return { isVueDeveloper: false } } } </script>
  • 30. Let’s become a Vue.js developer! index.vue <template> <div> <h1 v-if="isVueDeveloper"> Congratulations, you are a Vue.js developer! </h1> <h1 v-else> Click below to become a Vue.js developer. </h1> <button @click="isVueDeveloper = true"> Become a Vue.js developer </button> </div> </template> <script> export default { data () { return { isVueDeveloper: false } } } </script>
  • 31. Let’s become a Vue.js developer! index.vue <template> <div> <h1 v-if="isVueDeveloper"> Congratulations, you are a Vue.js developer! </h1> <h1 v-else> Click below to become a Vue.js developer. </h1> <button @click="becomeVueDeveloper"> Become a Vue.js developer </button> </div> </template> <script> export default { data () { return { isVueDeveloper: false } }, methods: { becomeVueDeveloper () { this.isVueDeveloper = true } } } </script>
  • 32. What is ES6 anyway? ES6 <script> export default { data () { return { isVueDeveloper: false } }, methods: { becomeVueDeveloper () { this.isVueDeveloper = true } } } </script> ES5 <script> module.exports = { data: function () { return { isVueDeveloper: false } }, methods: { becomeVueDeveloper: function () { this.isVueDeveloper = true } } } </script>
  • 33. Let’s become a better Vue.js developer! index.vue <template> <div> <h1> Click 5 times to become a better Vue.js developer. </h1> <button> Become a better Vue.js developer </button> </div> </template> ... <style> h1 { font-family: "Helvetica"; color: #41b883; } </style>
  • 34.
  • 35. Let’s become a better Vue.js developer! index.vue <template> <div> <h1> Click {{ clicksLeft }} times to become a better Vue.js developer. </h1> <button> Become a better Vue.js developer </button> </div> </template> ... <script> export default { data () { return { clicksLeft: 5 } } } </script>
  • 36.
  • 37. Let’s become a better Vue.js developer! index.vue <template> <div> <h1> Click {{ clicksLeft }} times to become a better Vue.js developer. </h1> <button @click="decrementClicks"> Become a better Vue.js developer </button> </div> </template> <script> export default { data () { return { clicksLeft: 5 } }, methods: { decrementClicks () { this.clicksLeft -= 1 } } } </script>
  • 38.
  • 39.
  • 40. Let’s become a better Vue.js developer! index.vue <template> <div> <h1> Click {{ clicksLeft }} times to become a better Vue.js developer. </h1> <button @click="decrementClicks"> Become a better Vue.js developer </button> </div> </template> <script> export default { data () { return { clicksLeft: 5 } }, methods: { decrementClicks () { if (this.clicksLeft > 0) { this.clicksLeft -= 1 } } } } </script>
  • 41.
  • 42.
  • 43. Let’s become a better Vue.js developer! index.vue <template> <div> <h1 v-if="clicksLeft === 0"> Congratulations, you are a better Vue.js developer! </h1> <h1 v-else> Click {{ clicksLeft }} times to become a better Vue.js developer. </h1> <button @click="decrementClicks"> Become a better Vue.js developer </button> </div> </template> <script> export default { data () { return { clicksLeft: 5 } }, methods: { decrementClicks () { if (this.clicksLeft > 0) { this.clicksLeft -= 1 } } } } </script>
  • 44.
  • 45.
  • 46. Looks familiar… Before <template> <div> <h1 v-if="isVueDeveloper"> Congratulations, you are a Vue.js developer! </h1> <h1 v-else> Click below to become a Vue.js developer. </h1> <button @click="becomeVueDeveloper"> Become a Vue.js developer </button> </div> </template> Now <template> <div> <h1 v-if="clicksLeft === 0"> Congratulations, you are a better Vue.js developer! </h1> <h1 v-else> Click {{ clicksLeft }} times to become a better Vue.js developer. </h1> <button @click="decrementClicks"> Become a better Vue.js developer </button> </div> </template>
  • 47. Let’s become a better Vue.js developer! index.vue <template> <div> <h1 v-if="isBetterVueDeveloper"> Congratulations, you are a better Vue.js developer! </h1> <h1 v-else> Click {{ clicksLeft }} times to become a better Vue.js developer. </h1> <button @click="decrementClicks"> Become a better Vue.js developer </button> </div> </template> <script> export default { data () { return { clicksLeft: 5 } }, computed: { isBetterVueDeveloper () { return this.clicksLeft === 0 } }, methods: { decrementClicks () { if (this.clicksLeft > 0) { this.clicksLeft -= 1 } } } } </script>
  • 48. What vs How? Declarative (yay!) ● what should be shown ● what data means ● what happens on interaction Imperative (nay) ● how should be rendered ● how data is computed ● how to update after changes WHAT HOW
  • 49. Let’s become a super Vue.js developer! index.vue <template> <div> <h1> Check all things below to become a super Vue.js developer 0/4 </h1> <ul> <li><input type="checkbox"> knows v-if &amp; v-else</li> <li><input type="checkbox"> knows methods &amp; computed</li> <li><input type="checkbox"> knows v-model</li> <li><input type="checkbox"> knows v-for</li> </ul> </div> </template> <style> h1 { font-family: "Helvetica"; color: #41b883; } li { list-style: none; font-size: 30px; } input[type="checkbox"] { width: 20px; height: 20px; } </style>
  • 50. Let’s become a super Vue.js developer! index.vue <template> <div> <h1> Check all things below to become a super Vue.js developer {{ checkedCount }}/4 </h1> <ul> <li> <input type="checkbox" v-model="isChecked"> knows v-if &amp; v-else </li> </ul> </div> </template> <script> export default { data () { return { isChecked: false } }, computed: { checkedCount () { if (this.isChecked) return 1 return 0 } } } </script>
  • 51. Let’s become a super Vue.js developer! index.vue <template> <div> <h1> Check all things below to become a super Vue.js developer {{ checkedCount }}/4 </h1> <ul> <li> <input type="checkbox" v-model="isChecked1"> knows v-if &amp; v-else </li> <li> <input type="checkbox" v-model="isChecked2"> knows methods &amp; computed </li> <li> <input type="checkbox" v-model="isChecked3"> knows v-model </li> <li> <input type="checkbox" v-model="isChecked4"> knows v-for </li> </ul> </div> </template> <script> export default { data () { return { isChecked1: false, isChecked2: false, isChecked3: false, isChecked4: false } }, computed: { checkedCount () { // A lot of ifs... } } } </script>
  • 54. Let’s become a super Vue.js developer! index.vue <template> <div> <h1> Check all things below to become a super Vue.js developer {{ checkedCount }}/4 </h1> <ul> <li v-for="item in items"> <input type="checkbox" v-model="item.isChecked"> knows v-if &amp; v-else </li> </ul> </div> </template> <script> export default { data () { return { items: [ { isChecked: false }, { isChecked: false }, { isChecked: false }, { isChecked: false } ] } }, computed: { checkedCount () { return 0 // TODO } } } </script>
  • 55. Let’s become a super Vue.js developer! index.vue <template> <div> <h1> Check all things below to become a super Vue.js developer {{ checkedCount }}/4 </h1> <ul> <li v-for="item in items"> <input type="checkbox" v-model="item.isChecked"> {{ item.description }} </li> </ul> </div> </template> <script> export default { data () { return { items: [ { isChecked: false, description: 'knows v-if & v-else' }, { isChecked: false, description: 'knows methods & computed' }, { isChecked: false, description: 'knows v-model' }, { isChecked: false, description: 'knows v-for' } ] } }, computed: { checkedCount () { return 0 // TODO } } } </script>
  • 56. Let’s become a super Vue.js developer! Imperative (how) computed: { checkedCount () { let count = 0 for (const item of this.items) { if (item.isChecked) { count += 1 } } return count } } Declarative (what) computed: { checkedCount () { return this.items .filter(item => item.isChecked) .length } }
  • 57. Let’s become a super Vue.js developer! index.vue <template> <div> <h1 v-if="isSuperVueDeveloper"> Congratulations, you are a super Vue.js developer! </h1> <template v-else> <h1> Check all things below to become a super Vue.js developer {{ checkedCount }}/4 </h1> <ul> <li v-for="item in items"> <input type="checkbox" v-model="item.isChecked"> {{ item.description }} </li> </ul> </template> </div> </template> <script> export default { data () { ... }, computed: { checkedCount () { return this.items .filter(item => item.isChecked) .length }, isSuperVueDeveloper () { return this.checkedCount === 4 } } } </script> different stuff
  • 58. Let’s become a super Vue.js developer! Magical numbers computed: { isSuperVueDeveloper () { return this.checkedCount === 4 } } Declarative logic computed: { isSuperVueDeveloper () { return this.checkedCount === this.items.length } }
  • 59. Let’s become a super Vue.js developer! index.vue <template> <div> <h1 v-if="isSuperVueDeveloper"> Congratulations, you are a super Vue.js developer! </h1> <template v-else> <h1> Check all things below to become a super Vue.js developer {{ checkedCount }}/{{ items.length }} </h1> <ul> <li v-for="item in items" :key="item.description"> <input type="checkbox" v-model="item.isChecked"> {{ item.description }} </li> </ul> </template> </div> </template>
  • 60. All together now!!! first-challenge.vue <template> <div> <h1 v-if="isVueDeveloper"> Congratulations, you are a Vue.js developer! ... second-challenge.vue <template> <div> <h1 v-if="isBetterVueDeveloper"> Congratulations, you are a better Vue.js developer! ... third-challenge.vue <template> <div> <h1 v-if="isSuperVueDeveloper"> Congratulations, you are a super Vue.js developer! ... <template> <main> <FirstChallenge /> <hr /> <SecondChallenge /> <hr /> <ThirdChallenge /> </main> </template> <script> import FirstChallenge from './first-challenge' import SecondChallenge from './second-challenge' import ThirdChallenge from './third-challenge' export default { components: { FirstChallenge, SecondChallenge, ThirdChallenge } } </script> index.vue
  • 61. What we learned Vue.js ● data binding ● v-if, v-else ● methods ● computed ● v-model ● v-for, :key Front-end ● components ● declarative style ● DRY
  • 62. What’s yet to learn ● communication between components ● routing ● scoped styles ● transitions ● dynamic styles ● Pug, SCSS/Sass/Stylus/PostCSS ● ... everything else!