how i fell in love with vuejs - github...

91
WITH VUEJS HOW I FELL IN LOVE

Upload: others

Post on 20-May-2020

7 views

Category:

Documents


0 download

TRANSCRIPT

Page 1: HOW I FELL IN LOVE WITH VUEJS - GitHub Pagesmattbrailsford.github.io/presentations/2018/04/27/how-i-fell-in-love-with-vuejs.pdfTHE WEB SEARCH. WHAT'S SO GOOD ABOUT IT? IT'S PROGRESSIVE

WITH VUEJSHOW I FELL IN LOVE

Page 2: HOW I FELL IN LOVE WITH VUEJS - GitHub Pagesmattbrailsford.github.io/presentations/2018/04/27/how-i-fell-in-love-with-vuejs.pdfTHE WEB SEARCH. WHAT'S SO GOOD ABOUT IT? IT'S PROGRESSIVE

@MATTBRAILSFORD - OUTFIELD DIGITALMATT BRAILSFORD

Page 3: HOW I FELL IN LOVE WITH VUEJS - GitHub Pagesmattbrailsford.github.io/presentations/2018/04/27/how-i-fell-in-love-with-vuejs.pdfTHE WEB SEARCH. WHAT'S SO GOOD ABOUT IT? IT'S PROGRESSIVE

WITH VUEJSHOW I FELL IN LOVE

Page 4: HOW I FELL IN LOVE WITH VUEJS - GitHub Pagesmattbrailsford.github.io/presentations/2018/04/27/how-i-fell-in-love-with-vuejs.pdfTHE WEB SEARCH. WHAT'S SO GOOD ABOUT IT? IT'S PROGRESSIVE
Page 5: HOW I FELL IN LOVE WITH VUEJS - GitHub Pagesmattbrailsford.github.io/presentations/2018/04/27/how-i-fell-in-love-with-vuejs.pdfTHE WEB SEARCH. WHAT'S SO GOOD ABOUT IT? IT'S PROGRESSIVE

THE YEAR WAS

Page 6: HOW I FELL IN LOVE WITH VUEJS - GitHub Pagesmattbrailsford.github.io/presentations/2018/04/27/how-i-fell-in-love-with-vuejs.pdfTHE WEB SEARCH. WHAT'S SO GOOD ABOUT IT? IT'S PROGRESSIVE
Page 7: HOW I FELL IN LOVE WITH VUEJS - GitHub Pagesmattbrailsford.github.io/presentations/2018/04/27/how-i-fell-in-love-with-vuejs.pdfTHE WEB SEARCH. WHAT'S SO GOOD ABOUT IT? IT'S PROGRESSIVE
Page 8: HOW I FELL IN LOVE WITH VUEJS - GitHub Pagesmattbrailsford.github.io/presentations/2018/04/27/how-i-fell-in-love-with-vuejs.pdfTHE WEB SEARCH. WHAT'S SO GOOD ABOUT IT? IT'S PROGRESSIVE
Page 9: HOW I FELL IN LOVE WITH VUEJS - GitHub Pagesmattbrailsford.github.io/presentations/2018/04/27/how-i-fell-in-love-with-vuejs.pdfTHE WEB SEARCH. WHAT'S SO GOOD ABOUT IT? IT'S PROGRESSIVE
Page 10: HOW I FELL IN LOVE WITH VUEJS - GitHub Pagesmattbrailsford.github.io/presentations/2018/04/27/how-i-fell-in-love-with-vuejs.pdfTHE WEB SEARCH. WHAT'S SO GOOD ABOUT IT? IT'S PROGRESSIVE
Page 11: HOW I FELL IN LOVE WITH VUEJS - GitHub Pagesmattbrailsford.github.io/presentations/2018/04/27/how-i-fell-in-love-with-vuejs.pdfTHE WEB SEARCH. WHAT'S SO GOOD ABOUT IT? IT'S PROGRESSIVE
Page 12: HOW I FELL IN LOVE WITH VUEJS - GitHub Pagesmattbrailsford.github.io/presentations/2018/04/27/how-i-fell-in-love-with-vuejs.pdfTHE WEB SEARCH. WHAT'S SO GOOD ABOUT IT? IT'S PROGRESSIVE
Page 13: HOW I FELL IN LOVE WITH VUEJS - GitHub Pagesmattbrailsford.github.io/presentations/2018/04/27/how-i-fell-in-love-with-vuejs.pdfTHE WEB SEARCH. WHAT'S SO GOOD ABOUT IT? IT'S PROGRESSIVE
Page 14: HOW I FELL IN LOVE WITH VUEJS - GitHub Pagesmattbrailsford.github.io/presentations/2018/04/27/how-i-fell-in-love-with-vuejs.pdfTHE WEB SEARCH. WHAT'S SO GOOD ABOUT IT? IT'S PROGRESSIVE

PLAYING THE

Page 15: HOW I FELL IN LOVE WITH VUEJS - GitHub Pagesmattbrailsford.github.io/presentations/2018/04/27/how-i-fell-in-love-with-vuejs.pdfTHE WEB SEARCH. WHAT'S SO GOOD ABOUT IT? IT'S PROGRESSIVE

THE PSYCHO

Page 16: HOW I FELL IN LOVE WITH VUEJS - GitHub Pagesmattbrailsford.github.io/presentations/2018/04/27/how-i-fell-in-love-with-vuejs.pdfTHE WEB SEARCH. WHAT'S SO GOOD ABOUT IT? IT'S PROGRESSIVE

THE FLING

Page 17: HOW I FELL IN LOVE WITH VUEJS - GitHub Pagesmattbrailsford.github.io/presentations/2018/04/27/how-i-fell-in-love-with-vuejs.pdfTHE WEB SEARCH. WHAT'S SO GOOD ABOUT IT? IT'S PROGRESSIVE

THE CLING-ON

Page 18: HOW I FELL IN LOVE WITH VUEJS - GitHub Pagesmattbrailsford.github.io/presentations/2018/04/27/how-i-fell-in-love-with-vuejs.pdfTHE WEB SEARCH. WHAT'S SO GOOD ABOUT IT? IT'S PROGRESSIVE

THE CHANGE-UP

Page 19: HOW I FELL IN LOVE WITH VUEJS - GitHub Pagesmattbrailsford.github.io/presentations/2018/04/27/how-i-fell-in-love-with-vuejs.pdfTHE WEB SEARCH. WHAT'S SO GOOD ABOUT IT? IT'S PROGRESSIVE

BUT THEN...

Page 20: HOW I FELL IN LOVE WITH VUEJS - GitHub Pagesmattbrailsford.github.io/presentations/2018/04/27/how-i-fell-in-love-with-vuejs.pdfTHE WEB SEARCH. WHAT'S SO GOOD ABOUT IT? IT'S PROGRESSIVE

THE SURPRISE

Page 21: HOW I FELL IN LOVE WITH VUEJS - GitHub Pagesmattbrailsford.github.io/presentations/2018/04/27/how-i-fell-in-love-with-vuejs.pdfTHE WEB SEARCH. WHAT'S SO GOOD ABOUT IT? IT'S PROGRESSIVE

BEGINSTHE COURTSHIP

Page 22: HOW I FELL IN LOVE WITH VUEJS - GitHub Pagesmattbrailsford.github.io/presentations/2018/04/27/how-i-fell-in-love-with-vuejs.pdfTHE WEB SEARCH. WHAT'S SO GOOD ABOUT IT? IT'S PROGRESSIVE

A LITTLE BACKGROUNDTHE WEB SEARCH

Page 23: HOW I FELL IN LOVE WITH VUEJS - GitHub Pagesmattbrailsford.github.io/presentations/2018/04/27/how-i-fell-in-love-with-vuejs.pdfTHE WEB SEARCH. WHAT'S SO GOOD ABOUT IT? IT'S PROGRESSIVE

WHAT'S SO GOODABOUT IT?

Page 24: HOW I FELL IN LOVE WITH VUEJS - GitHub Pagesmattbrailsford.github.io/presentations/2018/04/27/how-i-fell-in-love-with-vuejs.pdfTHE WEB SEARCH. WHAT'S SO GOOD ABOUT IT? IT'S PROGRESSIVE

IT'S PROGRESSIVEAS SIMPLE OR AS COMPLEX

AS YOU NEED

Page 25: HOW I FELL IN LOVE WITH VUEJS - GitHub Pagesmattbrailsford.github.io/presentations/2018/04/27/how-i-fell-in-love-with-vuejs.pdfTHE WEB SEARCH. WHAT'S SO GOOD ABOUT IT? IT'S PROGRESSIVE

IT'S SMALL63K MIN, 23K MIN + GZIP

Page 26: HOW I FELL IN LOVE WITH VUEJS - GitHub Pagesmattbrailsford.github.io/presentations/2018/04/27/how-i-fell-in-love-with-vuejs.pdfTHE WEB SEARCH. WHAT'S SO GOOD ABOUT IT? IT'S PROGRESSIVE

IT'S PERFORMANTON A PAR OR FASTER THAN

ANGULAR AND REACT

Page 27: HOW I FELL IN LOVE WITH VUEJS - GitHub Pagesmattbrailsford.github.io/presentations/2018/04/27/how-i-fell-in-love-with-vuejs.pdfTHE WEB SEARCH. WHAT'S SO GOOD ABOUT IT? IT'S PROGRESSIVE

IT'S FAMILIAR{{ }}, V-IF, V-FOR, V-BIND, V-ON

Page 28: HOW I FELL IN LOVE WITH VUEJS - GitHub Pagesmattbrailsford.github.io/presentations/2018/04/27/how-i-fell-in-love-with-vuejs.pdfTHE WEB SEARCH. WHAT'S SO GOOD ABOUT IT? IT'S PROGRESSIVE

IT'S REACTIVEEVENTS ON STEROIDS

Page 29: HOW I FELL IN LOVE WITH VUEJS - GitHub Pagesmattbrailsford.github.io/presentations/2018/04/27/how-i-fell-in-love-with-vuejs.pdfTHE WEB SEARCH. WHAT'S SO GOOD ABOUT IT? IT'S PROGRESSIVE

IT'S FRIENDLYGREAT DOCS AND DEV TOOLS

Page 30: HOW I FELL IN LOVE WITH VUEJS - GitHub Pagesmattbrailsford.github.io/presentations/2018/04/27/how-i-fell-in-love-with-vuejs.pdfTHE WEB SEARCH. WHAT'S SO GOOD ABOUT IT? IT'S PROGRESSIVE

WHO IS USING IT?

Page 31: HOW I FELL IN LOVE WITH VUEJS - GitHub Pagesmattbrailsford.github.io/presentations/2018/04/27/how-i-fell-in-love-with-vuejs.pdfTHE WEB SEARCH. WHAT'S SO GOOD ABOUT IT? IT'S PROGRESSIVE
Page 32: HOW I FELL IN LOVE WITH VUEJS - GitHub Pagesmattbrailsford.github.io/presentations/2018/04/27/how-i-fell-in-love-with-vuejs.pdfTHE WEB SEARCH. WHAT'S SO GOOD ABOUT IT? IT'S PROGRESSIVE

THE FIRST DATETHE FUNDAMENTALS

Page 33: HOW I FELL IN LOVE WITH VUEJS - GitHub Pagesmattbrailsford.github.io/presentations/2018/04/27/how-i-fell-in-love-with-vuejs.pdfTHE WEB SEARCH. WHAT'S SO GOOD ABOUT IT? IT'S PROGRESSIVE

<script src="/js/vue.js"></script>

Page 34: HOW I FELL IN LOVE WITH VUEJS - GitHub Pagesmattbrailsford.github.io/presentations/2018/04/27/how-i-fell-in-love-with-vuejs.pdfTHE WEB SEARCH. WHAT'S SO GOOD ABOUT IT? IT'S PROGRESSIVE

<!-- Input --><div id="app">{{ message }}</div>

<!-- Output --><div id="app">Hello World!</div>

var app = new Vue({el: '#app',data: {

message: 'Hello World!'}

});

Page 35: HOW I FELL IN LOVE WITH VUEJS - GitHub Pagesmattbrailsford.github.io/presentations/2018/04/27/how-i-fell-in-love-with-vuejs.pdfTHE WEB SEARCH. WHAT'S SO GOOD ABOUT IT? IT'S PROGRESSIVE

<!-- Input --><div id="app">{{ message }}</div>

<!-- Output --><div id="app">Hello World!</div>

var app = new Vue({el: '#app',data: {

message: 'Hello World!'}

});

Page 36: HOW I FELL IN LOVE WITH VUEJS - GitHub Pagesmattbrailsford.github.io/presentations/2018/04/27/how-i-fell-in-love-with-vuejs.pdfTHE WEB SEARCH. WHAT'S SO GOOD ABOUT IT? IT'S PROGRESSIVE

<!-- Input --><div id="app">{{ message }}</div>

<!-- Output --><div id="app">Hello World!</div>

var app = new Vue({el: '#app',data: {

message: 'Hello World!'}

});

Page 37: HOW I FELL IN LOVE WITH VUEJS - GitHub Pagesmattbrailsford.github.io/presentations/2018/04/27/how-i-fell-in-love-with-vuejs.pdfTHE WEB SEARCH. WHAT'S SO GOOD ABOUT IT? IT'S PROGRESSIVE

<!-- Input --><div id="app">{{ message }}</div>

<!-- Output --><div id="app">Hello Vue!</div>

var app = new Vue({el: '#app',data: {

message: 'Hello Vue!'}

});

Page 38: HOW I FELL IN LOVE WITH VUEJS - GitHub Pagesmattbrailsford.github.io/presentations/2018/04/27/how-i-fell-in-love-with-vuejs.pdfTHE WEB SEARCH. WHAT'S SO GOOD ABOUT IT? IT'S PROGRESSIVE

CORE FEATURES

Page 39: HOW I FELL IN LOVE WITH VUEJS - GitHub Pagesmattbrailsford.github.io/presentations/2018/04/27/how-i-fell-in-love-with-vuejs.pdfTHE WEB SEARCH. WHAT'S SO GOOD ABOUT IT? IT'S PROGRESSIVE

<!-- Conditional Rendering --><span v-if="type === 'A'">Type A</span><span v-else-if="type === 'B'">Type B</span><span v-else-if="type === 'C'">Type C</span><span v-else>Unknown Type</span>

<!-- Also --><span v-show="show">Visible</span>

Page 40: HOW I FELL IN LOVE WITH VUEJS - GitHub Pagesmattbrailsford.github.io/presentations/2018/04/27/how-i-fell-in-love-with-vuejs.pdfTHE WEB SEARCH. WHAT'S SO GOOD ABOUT IT? IT'S PROGRESSIVE

<!-- Looping --><ol><li v-for="todo in todos">

{{ todo.text }}</li>

</ol>

var app = new Vue({...,data: {

todos: [{ text: 'Todo 1' },{ text: 'Todo 2' },{ text: 'Todo 3' }

]}

})

Page 41: HOW I FELL IN LOVE WITH VUEJS - GitHub Pagesmattbrailsford.github.io/presentations/2018/04/27/how-i-fell-in-love-with-vuejs.pdfTHE WEB SEARCH. WHAT'S SO GOOD ABOUT IT? IT'S PROGRESSIVE

<!-- Attribute Binding --><a v-bind:href="myLink">Click me

</a>

<!-- Shorthand --><a :href="myLink">Click me

</a>

var app = new Vue({...,data: {

myLink: 'http://...'}

})

Page 42: HOW I FELL IN LOVE WITH VUEJS - GitHub Pagesmattbrailsford.github.io/presentations/2018/04/27/how-i-fell-in-love-with-vuejs.pdfTHE WEB SEARCH. WHAT'S SO GOOD ABOUT IT? IT'S PROGRESSIVE

<!-- Event Handling --><a v-on:click="doSomething">Click me

</a>

<!-- Shorthand --><a @click="doSomething">Click me

</a>

var app = new Vue({...,methods: {

doSomething: function() {// Do something

}}

})

Page 43: HOW I FELL IN LOVE WITH VUEJS - GitHub Pagesmattbrailsford.github.io/presentations/2018/04/27/how-i-fell-in-love-with-vuejs.pdfTHE WEB SEARCH. WHAT'S SO GOOD ABOUT IT? IT'S PROGRESSIVE

<!-- Watches --><div>{{ friendlyAge }}

</div>

var app = new Vue({...,data: {

age: 24,friendlyAge: ''

}watch: {

age: function(newVal, oldVal) {this.friendlyAge = newVal +

' years old';}

}})

Page 44: HOW I FELL IN LOVE WITH VUEJS - GitHub Pagesmattbrailsford.github.io/presentations/2018/04/27/how-i-fell-in-love-with-vuejs.pdfTHE WEB SEARCH. WHAT'S SO GOOD ABOUT IT? IT'S PROGRESSIVE

<!-- Computed Properties --><div>{{ friendlyAge }}

</div>

var app = new Vue({...,data: {

age: 24}computed: {

friendlyAge: function() {return this.age +

' years old';}

}})

Page 45: HOW I FELL IN LOVE WITH VUEJS - GitHub Pagesmattbrailsford.github.io/presentations/2018/04/27/how-i-fell-in-love-with-vuejs.pdfTHE WEB SEARCH. WHAT'S SO GOOD ABOUT IT? IT'S PROGRESSIVE

<!-- User Input --><input type="number"v-model.number="age" />

var app = new Vue({...,data: {

age: 24}

})

Page 46: HOW I FELL IN LOVE WITH VUEJS - GitHub Pagesmattbrailsford.github.io/presentations/2018/04/27/how-i-fell-in-love-with-vuejs.pdfTHE WEB SEARCH. WHAT'S SO GOOD ABOUT IT? IT'S PROGRESSIVE

LIFECYCLE

Page 47: HOW I FELL IN LOVE WITH VUEJS - GitHub Pagesmattbrailsford.github.io/presentations/2018/04/27/how-i-fell-in-love-with-vuejs.pdfTHE WEB SEARCH. WHAT'S SO GOOD ABOUT IT? IT'S PROGRESSIVE
Page 48: HOW I FELL IN LOVE WITH VUEJS - GitHub Pagesmattbrailsford.github.io/presentations/2018/04/27/how-i-fell-in-love-with-vuejs.pdfTHE WEB SEARCH. WHAT'S SO GOOD ABOUT IT? IT'S PROGRESSIVE

var app = new Vue({...,mounted: function () {

// Do something on mount},destroyed: function () {

// Do some cleanup}

})

Page 49: HOW I FELL IN LOVE WITH VUEJS - GitHub Pagesmattbrailsford.github.io/presentations/2018/04/27/how-i-fell-in-love-with-vuejs.pdfTHE WEB SEARCH. WHAT'S SO GOOD ABOUT IT? IT'S PROGRESSIVE

DEV TOOLS

Page 50: HOW I FELL IN LOVE WITH VUEJS - GitHub Pagesmattbrailsford.github.io/presentations/2018/04/27/how-i-fell-in-love-with-vuejs.pdfTHE WEB SEARCH. WHAT'S SO GOOD ABOUT IT? IT'S PROGRESSIVE
Page 51: HOW I FELL IN LOVE WITH VUEJS - GitHub Pagesmattbrailsford.github.io/presentations/2018/04/27/how-i-fell-in-love-with-vuejs.pdfTHE WEB SEARCH. WHAT'S SO GOOD ABOUT IT? IT'S PROGRESSIVE
Page 52: HOW I FELL IN LOVE WITH VUEJS - GitHub Pagesmattbrailsford.github.io/presentations/2018/04/27/how-i-fell-in-love-with-vuejs.pdfTHE WEB SEARCH. WHAT'S SO GOOD ABOUT IT? IT'S PROGRESSIVE

THE SECOND DATECOMPONENTS

Page 53: HOW I FELL IN LOVE WITH VUEJS - GitHub Pagesmattbrailsford.github.io/presentations/2018/04/27/how-i-fell-in-love-with-vuejs.pdfTHE WEB SEARCH. WHAT'S SO GOOD ABOUT IT? IT'S PROGRESSIVE

<!-- One Giant View --><button v-on:click="count1++">You clicked me {{ count1 }} times.</button>

<button v-on:click="count2++">You clicked me {{ count2 }} times.</button>

<button v-on:click="count3++">You clicked me {{ count3 }} times.</button>

var app = new Vue({...,data: {

count1: 0,count2: 0,count3: 0

}})

Page 54: HOW I FELL IN LOVE WITH VUEJS - GitHub Pagesmattbrailsford.github.io/presentations/2018/04/27/how-i-fell-in-love-with-vuejs.pdfTHE WEB SEARCH. WHAT'S SO GOOD ABOUT IT? IT'S PROGRESSIVE

<!-- Componentised View --><div id="app"><button-counter /><button-counter /><button-counter />

</div>

Vue.component(...)

var app = new Vue({el: '#app'

})

Page 55: HOW I FELL IN LOVE WITH VUEJS - GitHub Pagesmattbrailsford.github.io/presentations/2018/04/27/how-i-fell-in-love-with-vuejs.pdfTHE WEB SEARCH. WHAT'S SO GOOD ABOUT IT? IT'S PROGRESSIVE

Vue.component('button-counter', {data: function () {

return {count: 0

}},template: '<button v-on:click="count++">You clicked me

{{ count }} times.</button>'})

Page 56: HOW I FELL IN LOVE WITH VUEJS - GitHub Pagesmattbrailsford.github.io/presentations/2018/04/27/how-i-fell-in-love-with-vuejs.pdfTHE WEB SEARCH. WHAT'S SO GOOD ABOUT IT? IT'S PROGRESSIVE

Vue.component('button-counter', {data: function () {

return {count: 0

}},template: '<button v-on:click="count++">You clicked me

{{ count }} times.</button>'})

Page 57: HOW I FELL IN LOVE WITH VUEJS - GitHub Pagesmattbrailsford.github.io/presentations/2018/04/27/how-i-fell-in-love-with-vuejs.pdfTHE WEB SEARCH. WHAT'S SO GOOD ABOUT IT? IT'S PROGRESSIVE

Vue.component('button-counter', {data: function () {

return {count: 0

}},template: '<button v-on:click="count++">You clicked me

{{ count }} times.</button>'})

Page 58: HOW I FELL IN LOVE WITH VUEJS - GitHub Pagesmattbrailsford.github.io/presentations/2018/04/27/how-i-fell-in-love-with-vuejs.pdfTHE WEB SEARCH. WHAT'S SO GOOD ABOUT IT? IT'S PROGRESSIVE

Vue.component('button-counter', {data: function () {

return {count: 0

}},template: '<button v-on:click="count++">You clicked me

{{ count }} times.</button>'})

Page 59: HOW I FELL IN LOVE WITH VUEJS - GitHub Pagesmattbrailsford.github.io/presentations/2018/04/27/how-i-fell-in-love-with-vuejs.pdfTHE WEB SEARCH. WHAT'S SO GOOD ABOUT IT? IT'S PROGRESSIVE

<!-- Componentised View --><div id="app"><button-counter /><button-counter /><button-counter />

</div>

Vue.component(...)

var app = new Vue({el: '#app'

})

Page 60: HOW I FELL IN LOVE WITH VUEJS - GitHub Pagesmattbrailsford.github.io/presentations/2018/04/27/how-i-fell-in-love-with-vuejs.pdfTHE WEB SEARCH. WHAT'S SO GOOD ABOUT IT? IT'S PROGRESSIVE

X-TEMPLATES

Page 61: HOW I FELL IN LOVE WITH VUEJS - GitHub Pagesmattbrailsford.github.io/presentations/2018/04/27/how-i-fell-in-love-with-vuejs.pdfTHE WEB SEARCH. WHAT'S SO GOOD ABOUT IT? IT'S PROGRESSIVE

Vue.component('button-counter', {data: function () {

return {count: 0

}},template: '<button v-on:click="count++">You clicked me

{{ count }} times.</button>'})

Page 62: HOW I FELL IN LOVE WITH VUEJS - GitHub Pagesmattbrailsford.github.io/presentations/2018/04/27/how-i-fell-in-love-with-vuejs.pdfTHE WEB SEARCH. WHAT'S SO GOOD ABOUT IT? IT'S PROGRESSIVE

<script type="text/x-template" id="button-counter"><button v-on:click="count++">You clicked me

{{ count }} times.</button></script>

Page 63: HOW I FELL IN LOVE WITH VUEJS - GitHub Pagesmattbrailsford.github.io/presentations/2018/04/27/how-i-fell-in-love-with-vuejs.pdfTHE WEB SEARCH. WHAT'S SO GOOD ABOUT IT? IT'S PROGRESSIVE

Vue.component('button-counter', {data: function () {

return {count: 0

}},template: '#button-counter'

})

Page 64: HOW I FELL IN LOVE WITH VUEJS - GitHub Pagesmattbrailsford.github.io/presentations/2018/04/27/how-i-fell-in-love-with-vuejs.pdfTHE WEB SEARCH. WHAT'S SO GOOD ABOUT IT? IT'S PROGRESSIVE

PASSING DATA

Page 65: HOW I FELL IN LOVE WITH VUEJS - GitHub Pagesmattbrailsford.github.io/presentations/2018/04/27/how-i-fell-in-love-with-vuejs.pdfTHE WEB SEARCH. WHAT'S SO GOOD ABOUT IT? IT'S PROGRESSIVE

PARENT CHILD

PROPS

EVENTS

Page 66: HOW I FELL IN LOVE WITH VUEJS - GitHub Pagesmattbrailsford.github.io/presentations/2018/04/27/how-i-fell-in-love-with-vuejs.pdfTHE WEB SEARCH. WHAT'S SO GOOD ABOUT IT? IT'S PROGRESSIVE

Vue.component('star-rating', {props: ['rating'],template: '#star-rating'

})

Page 67: HOW I FELL IN LOVE WITH VUEJS - GitHub Pagesmattbrailsford.github.io/presentations/2018/04/27/how-i-fell-in-love-with-vuejs.pdfTHE WEB SEARCH. WHAT'S SO GOOD ABOUT IT? IT'S PROGRESSIVE

<script type="text/x-template" id="star-rating"><div class="star-rating">

<a :class="{ highlight: rating >== 1 }">★</a><a :class="{ highlight: rating >== 2 }">★</a><a :class="{ highlight: rating >== 3 }">★</a><a :class="{ highlight: rating >== 4 }">★</a><a :class="{ highlight: rating === 5 }">★</a>

</div></script>

Page 68: HOW I FELL IN LOVE WITH VUEJS - GitHub Pagesmattbrailsford.github.io/presentations/2018/04/27/how-i-fell-in-love-with-vuejs.pdfTHE WEB SEARCH. WHAT'S SO GOOD ABOUT IT? IT'S PROGRESSIVE

<div v-for="product in products"><star-rating :rating="product.rating" />

</div>

Page 69: HOW I FELL IN LOVE WITH VUEJS - GitHub Pagesmattbrailsford.github.io/presentations/2018/04/27/how-i-fell-in-love-with-vuejs.pdfTHE WEB SEARCH. WHAT'S SO GOOD ABOUT IT? IT'S PROGRESSIVE

★★★★★

Page 70: HOW I FELL IN LOVE WITH VUEJS - GitHub Pagesmattbrailsford.github.io/presentations/2018/04/27/how-i-fell-in-love-with-vuejs.pdfTHE WEB SEARCH. WHAT'S SO GOOD ABOUT IT? IT'S PROGRESSIVE

<script type="text/x-template" id="star-rating"><div class="star-rating">

<a :class="{ highlight: rating >== 1 }"@click="setRating(1)">★</a>

....</div>

</script>

Page 71: HOW I FELL IN LOVE WITH VUEJS - GitHub Pagesmattbrailsford.github.io/presentations/2018/04/27/how-i-fell-in-love-with-vuejs.pdfTHE WEB SEARCH. WHAT'S SO GOOD ABOUT IT? IT'S PROGRESSIVE

Vue.component('star-rating', {props: ['rating'],template: '#star-rating',methods: {

setRating: function (newRating) {this.rating = newRating;

}}

})

Page 72: HOW I FELL IN LOVE WITH VUEJS - GitHub Pagesmattbrailsford.github.io/presentations/2018/04/27/how-i-fell-in-love-with-vuejs.pdfTHE WEB SEARCH. WHAT'S SO GOOD ABOUT IT? IT'S PROGRESSIVE

Vue.component('star-rating', {props: ['rating'],template: '#star-rating',methods: {

setRating: function (newRating) {this.rating = newRating;this.$emit('rating-changed', newRating);

}}

})

Page 73: HOW I FELL IN LOVE WITH VUEJS - GitHub Pagesmattbrailsford.github.io/presentations/2018/04/27/how-i-fell-in-love-with-vuejs.pdfTHE WEB SEARCH. WHAT'S SO GOOD ABOUT IT? IT'S PROGRESSIVE

<div v-for="product in products"><star-rating :rating="product.rating"

@rating-changed="handleRatingChanged" /></div>

Page 74: HOW I FELL IN LOVE WITH VUEJS - GitHub Pagesmattbrailsford.github.io/presentations/2018/04/27/how-i-fell-in-love-with-vuejs.pdfTHE WEB SEARCH. WHAT'S SO GOOD ABOUT IT? IT'S PROGRESSIVE

<div v-for="product in products"><star-rating v-model="product.rating" />

</div>

Page 75: HOW I FELL IN LOVE WITH VUEJS - GitHub Pagesmattbrailsford.github.io/presentations/2018/04/27/how-i-fell-in-love-with-vuejs.pdfTHE WEB SEARCH. WHAT'S SO GOOD ABOUT IT? IT'S PROGRESSIVE

Vue.component('star-rating', {model: {

prop: 'rating',event: 'rating-changed'

},props: ['rating'],template: '#star-rating',methods: {

setRating: function (newRating) {this.rating = newRating;this.$emit('rating-changed', newRating);

}}

})

Page 76: HOW I FELL IN LOVE WITH VUEJS - GitHub Pagesmattbrailsford.github.io/presentations/2018/04/27/how-i-fell-in-love-with-vuejs.pdfTHE WEB SEARCH. WHAT'S SO GOOD ABOUT IT? IT'S PROGRESSIVE
Page 77: HOW I FELL IN LOVE WITH VUEJS - GitHub Pagesmattbrailsford.github.io/presentations/2018/04/27/how-i-fell-in-love-with-vuejs.pdfTHE WEB SEARCH. WHAT'S SO GOOD ABOUT IT? IT'S PROGRESSIVE

THE THIRD DATESFC'S & BUILD PROCESS

Page 78: HOW I FELL IN LOVE WITH VUEJS - GitHub Pagesmattbrailsford.github.io/presentations/2018/04/27/how-i-fell-in-love-with-vuejs.pdfTHE WEB SEARCH. WHAT'S SO GOOD ABOUT IT? IT'S PROGRESSIVE

<!-- my-component.vue --><template>

<div class="my-component">{{ greeting }} World!</div></template>

<script>export default {

data () {return { greeting: 'Hello' }

}}

</script>

<style lang="scss" scoped>.my-component { color: #BADA55; }

</style>

Page 79: HOW I FELL IN LOVE WITH VUEJS - GitHub Pagesmattbrailsford.github.io/presentations/2018/04/27/how-i-fell-in-love-with-vuejs.pdfTHE WEB SEARCH. WHAT'S SO GOOD ABOUT IT? IT'S PROGRESSIVE

import MyComponent from './my-component.vue'

new Vue({...,components: { MyComponent }

})

Page 80: HOW I FELL IN LOVE WITH VUEJS - GitHub Pagesmattbrailsford.github.io/presentations/2018/04/27/how-i-fell-in-love-with-vuejs.pdfTHE WEB SEARCH. WHAT'S SO GOOD ABOUT IT? IT'S PROGRESSIVE

npm install -g @vue/clivue create my-project

Page 81: HOW I FELL IN LOVE WITH VUEJS - GitHub Pagesmattbrailsford.github.io/presentations/2018/04/27/how-i-fell-in-love-with-vuejs.pdfTHE WEB SEARCH. WHAT'S SO GOOD ABOUT IT? IT'S PROGRESSIVE
Page 82: HOW I FELL IN LOVE WITH VUEJS - GitHub Pagesmattbrailsford.github.io/presentations/2018/04/27/how-i-fell-in-love-with-vuejs.pdfTHE WEB SEARCH. WHAT'S SO GOOD ABOUT IT? IT'S PROGRESSIVE

cd my-projectnpm run serve# ornpm run build

Page 83: HOW I FELL IN LOVE WITH VUEJS - GitHub Pagesmattbrailsford.github.io/presentations/2018/04/27/how-i-fell-in-love-with-vuejs.pdfTHE WEB SEARCH. WHAT'S SO GOOD ABOUT IT? IT'S PROGRESSIVE
Page 84: HOW I FELL IN LOVE WITH VUEJS - GitHub Pagesmattbrailsford.github.io/presentations/2018/04/27/how-i-fell-in-love-with-vuejs.pdfTHE WEB SEARCH. WHAT'S SO GOOD ABOUT IT? IT'S PROGRESSIVE

THE FUTURETHIS IS JUST THE BEGINING

Page 85: HOW I FELL IN LOVE WITH VUEJS - GitHub Pagesmattbrailsford.github.io/presentations/2018/04/27/how-i-fell-in-love-with-vuejs.pdfTHE WEB SEARCH. WHAT'S SO GOOD ABOUT IT? IT'S PROGRESSIVE

ROUTING STATE MANAGEMENTSERVER SIDE RENDERINGSTATIC SITE GENERATIONSPAS NATIVE APPS PLUGINS

AND MORE ...

Page 86: HOW I FELL IN LOVE WITH VUEJS - GitHub Pagesmattbrailsford.github.io/presentations/2018/04/27/how-i-fell-in-love-with-vuejs.pdfTHE WEB SEARCH. WHAT'S SO GOOD ABOUT IT? IT'S PROGRESSIVE

HTTPS://VUEJS.ORG/V2/GUIDE/

Page 87: HOW I FELL IN LOVE WITH VUEJS - GitHub Pagesmattbrailsford.github.io/presentations/2018/04/27/how-i-fell-in-love-with-vuejs.pdfTHE WEB SEARCH. WHAT'S SO GOOD ABOUT IT? IT'S PROGRESSIVE

HAPPY EVER AFTERTO SUMMARISE

Page 88: HOW I FELL IN LOVE WITH VUEJS - GitHub Pagesmattbrailsford.github.io/presentations/2018/04/27/how-i-fell-in-love-with-vuejs.pdfTHE WEB SEARCH. WHAT'S SO GOOD ABOUT IT? IT'S PROGRESSIVE

LAST THINGSONE TWO

Page 89: HOW I FELL IN LOVE WITH VUEJS - GitHub Pagesmattbrailsford.github.io/presentations/2018/04/27/how-i-fell-in-love-with-vuejs.pdfTHE WEB SEARCH. WHAT'S SO GOOD ABOUT IT? IT'S PROGRESSIVE

THE UMBRACO DEVELOPER UNCONFERENCE

CODECAB.IN | 12TH - 18TH OCTOBER 2018

Page 90: HOW I FELL IN LOVE WITH VUEJS - GitHub Pagesmattbrailsford.github.io/presentations/2018/04/27/how-i-fell-in-love-with-vuejs.pdfTHE WEB SEARCH. WHAT'S SO GOOD ABOUT IT? IT'S PROGRESSIVE

HTTPS://PATREON.COM/UMCO

Page 91: HOW I FELL IN LOVE WITH VUEJS - GitHub Pagesmattbrailsford.github.io/presentations/2018/04/27/how-i-fell-in-love-with-vuejs.pdfTHE WEB SEARCH. WHAT'S SO GOOD ABOUT IT? IT'S PROGRESSIVE

THANK YOU@MATTBRAILSFORD - OUTFIELD DIGITAL