SlideShare a Scribd company logo
The Point of
Exploring JavaScript Frameworks
Holly Schinsky
devgirlfl
devgirl.org
The Progressive
JavaScript Framework
Vue.js is…
Creator - Evan You
Initial release in Feb 2014
Previously worked at Google
and Meteor
Works on Vue full time
Funded by the Patreon
campaign
“…what if I could just extract the part that I really liked about
Angular and build something really lightweight
without all the extra concepts involved?”
Why Vue?
Approachable
Scalable
… makes developers happy :)
Productive
It’s Popular
and growing…
Vue Features
Reactive Interfaces
Declarative Rendering
Data Binding
Directives
Template Logic
Components
Event Handling
Computed Properties
CSS Transitions and Animations
Filters
See vuejs.org for full details
Vue Basics
Apps are made up of nested and reusable components
<div id="app">
<app-nav></app-nav>
<app-view>
<app-sidebar></app-sidebar>
<app-content></app-content>
</app-view>
</div>
Simple Vue Example
var demo = new Vue({
el: '#demo',
data: {
message: ‘Vue is the best!’
}
})
<div id="demo">
<p>{{ message }}</p>
<input v-model="message">
</div>
<html>	
<head>	
<title>My	VueJs	App</title>	
</head>	
<body>	
				
<!--	Container	for	Vue	instance	to	manage	-->	
			<div	id="app">							
			</div>	
</body>	
</html>
<!--	include	Vue.js	in	our	page	-->	
<script	src=“https://unpkg.com/vue”></script>
				<script>								
//	create	a	new	Vue	instance	mounted	to	app		
						var	vm	=	new	Vue({	
								el:	'#app'	
						});	
				</script>	
Quick Start
index.html
<html>	
<body>	
//..	
<!--	Container	for	Vue	instance	to	manage	-->	
				<div	id=“app”>	
				</div>	
				
<script	src=“https://unpkg.com/vue”></script>	
				<script>	
			
						
//	create	a	new	Vue	instance	and	mount	it	to	app	div	
							var	vm	=	new	Vue({	
											el:	'#app'	
							});	
				</script>	
//…	
<template	id="hello-template">	
		<div>	
<h1>Hello	World!</h1>													
		</div>	
</template>	
//	Register	the	hello	component	
Vue.component('hello',	{	
			template:	'#hello-template'	
});
<hello></hello>
Quick Start
index.html
Component Registration
Vue.component('hello', {
template: '#hello-template',
// ...
})
new Vue({
el: '#app',
// ...
}
Global
var Goodbye = {
template: '<div> Goodbye World!</div>'
}
Vue.component('hello', {
template: '#hello-template',
components: {
'Goodbye': Goodbye
}
});
Local
import Hello from './components/Hello'
export default {
name: 'app',
components: {
Hello
},
// ...
}
Local by Module
Defined before root app instance
<template>	
		<div	class="hello">	
				<h1>{{	msg	}}</h1>	
		</div>	
</template>	
<script>	
export	default	{	
		name:	'hello',	
		data	()	{	
				return	{	
						msg:	'Welcome	to	Your	Vue.js	App'	
		}	
</script>	
<style	scoped>	
h1,	h2	{	
		font-weight:	normal;	
}	
.hello	{	
color:	magenta;	
}	
</style>
Single file .vue
components
hello.vue
Templates
<h1>Msg: {{ msg.split('').reverse().join('') }}</h1>
Support JavaScript expressions
<h1>Message: {{ msg }}</h1>
Mustache-like syntax for basic text interpolation (like Angular)
Use v-bind	directive (or : prefix) within an HTML attribute
<button :disabled="isButtonDisabled">Go</button>
<div v-bind:id="dynamicId"></div>
Vue Data
- v-model directive allows two-way binding on form elements
Vue.component('demo', {
template: ‘#demo-template',
data: function () {
return {
fname: 'Holly',
lname: 'Schinsky',
isDisabled: false,
items: ['Milk','Bread','Cereal','Peanut Butter'],
counter: 0
}
},
- When data items change, the view ‘reacts’ automatically to them
- Data properties are only reactive if they existed when the instance was
created
<input type="text" v-model="message"/>
Props
Vue.component('hello', {
template: '#hello-template',
props: ['message'],
data: function () {
return {
fname: 'Holly',
lname: 'Schinsky',
}
}
})
<hello v-bind:message=“message"></hello>
<h1>{{ message }}</h1>
hello component
uses
parent component
passes
Events
<button @click="addToCount">Add 1</button>
<button v-on:click="addMore(4, $event)">Add 4</button>
Use v-on or @ prefix (shorthand)
<input v-on:keyup.enter="submit">
<a v-on:click.stop="doThis"></a>
Modifiers restrict handling to certain specific events
Directives v-text	
v-html	
v-show	
v-if	
v-else	
v-else-if	
v-for	
v-on	
v-bind	
v-model	
v-pre	
v-cloak	
v-once	
<input type="text" v-model="message"/>
<li v-for="item in items">
{{ item }}
</li>
<button v-on:click="counter+=1">Add 1</button>
<textarea v-bind:disabled='isDisabled' v-bind:class='{ disabled:
isDisabled }'>{{ taVal }} </textarea>
<h1 v-if="isWinner">Winner winner chicken dinner!</h1>
<h1 v-else>Sorry about your luck</h1>
Filters
<!-- in text interpolation -->
{{ message | capitalize }}
<!-- in v-bind -->
<div v-bind:id="rawId | formatId"></div>
Use the pipe | symbol to add a filter function:
Define filter function in instance options:
new Vue({
// …
filters: {
capitalize: function (value) {
if (!value) return ''
return value.toString().toUpperCase();
}
}
})
Computed Properties
- Computed properties are cached based on their dependencies.
- Use for more complex logic to keep it out of your HTML or for
things that don’t require reactive properties
Vue.component('demo', {
template: ‘#demo-template',
//..
computed: {
fullName: function () {
return this.fname + ' ' + this.lname;
}
}
new Vue({
data: {
a: 1
},
created: function () {
console.log('a is: ' + this.a)
}
})
// => "a is: 1"
created(),	mounted(),	updated(),	destroyed()	etc
Lifecycle Hooks
Run code at different stages of a Vue component lifecycle
https://vuejs.org/v2/guide/instance.html#Instance-Lifecycle-Hooks
Vue CLI
$	npm	install	-g	vue-cli
$	vue	init	<template-name>	<project-name>
$	vue	init	webpack	my-vue-app
Vue DevTools
https://github.com/vuejs/vue-devtools
Framework Similarities
- Vue and Angular
- Similar templates
- Use of directives syntax (ie: {{	}} and v-if to ng-if	
etc)	
- Some automatic data binding
- Vue and React
- Uses a Virtual DOM
- View layer focused
- Reactive components
Framework Differences
- Vue vs Angular
- Not an opinionated stack, core focus is on the View layer
- Data binding in a one way data flow from parent to child
- Much smaller file size (20KB min+gzip)
- No dirty checking
- Works without additional tooling
- Vue vs React
- Gives you a visually scannable template with encapsulated logic
- Templates vs JSX (less CPU)
- Faster ramp up vs less intuitive (JSX)
- Less boilerplate code needed in Vue
- Vue works out of the box (without a build system)
Angular vs Vue
import { Component } from '@angular/core';
@Component ({
selector: 'my-app',
template: `<h1>Hello {{name}}</h1>`,
})
export class AppComponent { name = 'Angular'; }
var helloApp =
angular.module("helloApp", []);
    helloApp.controller("HelloCtrl",
function($scope) {
        $scope.name = "Calvin Hobbes";
    });
<div id="app">
{{ message }}
</div>
var app = new Vue({
el: '#app',
data: {
message: 'Hello Vue!'
}
})
Angular 1
Angular 2
Vue
React vs Vue
var HelloMessage = React.createClass({
render: function () {
return <h1>Hello {this.props.message}!</h1>;
}
});
ReactDOM.render(<HelloMessage message="World" />,
document.getElementById('root'));
<div id="app">
{{ message }}
</div>
var app = new Vue({
el: '#app',
data: {
message: 'Hello Vue!'
}
})
React
Vue
Vue and Mobile
Small file size of Vue.js lends itself well to mobile
Several UI libraries available with bindings
Framework7 - https://framework7.io/vue/
Onsen UI - https://onsen.io/vue/
Get started quickly using PhoneGap starter project
templates - https://github.com/phonegap/phonegap-app-
stockpile
vuex - state management - https://vuex.vuejs.org
vue-router - routing between views in your SPA -
https://router.vuejs.org/en/
axios - HTTP Request library - https://github.com/
axios/axios
Popular Add-ons
Resources
https://css-tricks.com/intro-to-vue-1-rendering-directives-events/
https://github.com/vuejs/awesome-vue
https://madewithvuejs.com/
https://alligator.io/vuejs/component-lifecycle/
https://vuejs.org/2016/02/06/common-gotchas/
https://github.com/chrisvfritz/vue-2.0-simple-routing-example

More Related Content

PDF
Why Vue.js?
Jonathan Goode
 
PDF
Intro to vue.js
TechMagic
 
PDF
Vue.js
Jadson Santos
 
ODP
An Introduction to Vuejs
Paddy Lock
 
PDF
introduction to Vue.js 3
ArezooKmn
 
ODP
Basics of VueJS
Squash Apps Pvt Ltd
 
PDF
NodeJS for Beginner
Apaichon Punopas
 
PPTX
Basics of Vue.js 2019
Paul Bele
 
Why Vue.js?
Jonathan Goode
 
Intro to vue.js
TechMagic
 
An Introduction to Vuejs
Paddy Lock
 
introduction to Vue.js 3
ArezooKmn
 
Basics of VueJS
Squash Apps Pvt Ltd
 
NodeJS for Beginner
Apaichon Punopas
 
Basics of Vue.js 2019
Paul Bele
 

What's hot (20)

PPT
Vue.js Getting Started
Murat Doğan
 
PDF
VueJS Introduction
David Ličen
 
PPTX
Angular 9
Raja Vishnu
 
PDF
An introduction to Vue.js
Javier Lafora Rey
 
PPTX
Angular introduction students
Christian John Felix
 
PPTX
An Overview on Nuxt.js
Squash Apps Pvt Ltd
 
PDF
Introdução ao React
Luiz Paulo dos Prazeres Júnior
 
PDF
VueJS: The Simple Revolution
Rafael Casuso Romate
 
PDF
Vue, vue router, vuex
Samundra khatri
 
PPTX
An introduction to Vue.js
Pagepro
 
PDF
Vue.js for beginners
Julio Bitencourt
 
PPTX
Introduction to Node.js
AMD Developer Central
 
PDF
Docker란 무엇인가? : Docker 기본 사용법
pyrasis
 
PDF
[AWS Dev Day] 실습워크샵 | Amazon EKS 핸즈온 워크샵
Amazon Web Services Korea
 
PDF
Introduction to ReactJS
Hoang Long
 
PPTX
Jenkins tutorial
Mamun Rashid, CCDH
 
PDF
이벤트 기반 분산 시스템을 향한 여정
Arawn Park
 
PDF
Vue JS Intro
Muhammad Rizki Rijal
 
PPTX
[NDC17] Kubernetes로 개발서버 간단히 찍어내기
SeungYong Oh
 
PPTX
Node.js Express
Eyal Vardi
 
Vue.js Getting Started
Murat Doğan
 
VueJS Introduction
David Ličen
 
Angular 9
Raja Vishnu
 
An introduction to Vue.js
Javier Lafora Rey
 
Angular introduction students
Christian John Felix
 
An Overview on Nuxt.js
Squash Apps Pvt Ltd
 
Introdução ao React
Luiz Paulo dos Prazeres Júnior
 
VueJS: The Simple Revolution
Rafael Casuso Romate
 
Vue, vue router, vuex
Samundra khatri
 
An introduction to Vue.js
Pagepro
 
Vue.js for beginners
Julio Bitencourt
 
Introduction to Node.js
AMD Developer Central
 
Docker란 무엇인가? : Docker 기본 사용법
pyrasis
 
[AWS Dev Day] 실습워크샵 | Amazon EKS 핸즈온 워크샵
Amazon Web Services Korea
 
Introduction to ReactJS
Hoang Long
 
Jenkins tutorial
Mamun Rashid, CCDH
 
이벤트 기반 분산 시스템을 향한 여정
Arawn Park
 
Vue JS Intro
Muhammad Rizki Rijal
 
[NDC17] Kubernetes로 개발서버 간단히 찍어내기
SeungYong Oh
 
Node.js Express
Eyal Vardi
 
Ad

Similar to The Point of Vue - Intro to Vue.js (20)

PDF
Vue js 2.x
Suresh Velusamy
 
PDF
Vue.js - An Introduction
saadulde
 
PDF
ITB2019 ColdBox APIs + VueJS - powering Mobile, Desktop and Web Apps with 1 V...
Ortus Solutions, Corp
 
PPTX
An introduction to Vue.js
TO THE NEW Pvt. Ltd.
 
PDF
Introduction to Vue.js
Meir Rotstein
 
PPTX
ColdBox APIs + VueJS - powering Mobile, Desktop and Web Apps with 1 VueJS cod...
Gavin Pickin
 
PDF
Vue.js
BADR
 
PDF
Meet VueJs
Mathieu Breton
 
PPTX
Level up apps and websites with vue.js
Commit University
 
PPTX
Level up apps and websites with vue.js
Violetta Villani
 
PPTX
Introduction to Vue.js DevStaff Meetup 13.02
Paul Bele
 
PDF
Love at first Vue
Dalibor Gogic
 
PPTX
Introduction to web application development with Vue (for absolute beginners)...
Lucas Jellema
 
PPTX
Vue 2.0 + Vuex Router & Vuex at Vue.js
Takuya Tejima
 
PPTX
Vue.js Use Cases
GlobalLogic Ukraine
 
PPTX
Passionate People Meetup - React vs Vue with a deepdive into Proxies
Harijs Deksnis
 
PPTX
Membangun Moderen UI dengan Vue.js
Froyo Framework
 
PDF
Vue fundamentasl with Testing and Vuex
Christoffer Noring
 
PDF
Progressive Javascript: Why React when you can Vue?
Sonal Raj
 
Vue js 2.x
Suresh Velusamy
 
Vue.js - An Introduction
saadulde
 
ITB2019 ColdBox APIs + VueJS - powering Mobile, Desktop and Web Apps with 1 V...
Ortus Solutions, Corp
 
An introduction to Vue.js
TO THE NEW Pvt. Ltd.
 
Introduction to Vue.js
Meir Rotstein
 
ColdBox APIs + VueJS - powering Mobile, Desktop and Web Apps with 1 VueJS cod...
Gavin Pickin
 
Vue.js
BADR
 
Meet VueJs
Mathieu Breton
 
Level up apps and websites with vue.js
Commit University
 
Level up apps and websites with vue.js
Violetta Villani
 
Introduction to Vue.js DevStaff Meetup 13.02
Paul Bele
 
Love at first Vue
Dalibor Gogic
 
Introduction to web application development with Vue (for absolute beginners)...
Lucas Jellema
 
Vue 2.0 + Vuex Router & Vuex at Vue.js
Takuya Tejima
 
Vue.js Use Cases
GlobalLogic Ukraine
 
Passionate People Meetup - React vs Vue with a deepdive into Proxies
Harijs Deksnis
 
Membangun Moderen UI dengan Vue.js
Froyo Framework
 
Vue fundamentasl with Testing and Vuex
Christoffer Noring
 
Progressive Javascript: Why React when you can Vue?
Sonal Raj
 
Ad

Recently uploaded (20)

DOCX
SAR - EEEfdfdsdasdsdasdasdasdasdasdasdasda.docx
Kanimozhi676285
 
PDF
Queuing formulas to evaluate throughputs and servers
gptshubham
 
PPTX
Civil Engineering Practices_BY Sh.JP Mishra 23.09.pptx
bineetmishra1990
 
PDF
The Effect of Artifact Removal from EEG Signals on the Detection of Epileptic...
Partho Prosad
 
PPT
Ppt for engineering students application on field effect
lakshmi.ec
 
PPTX
easa module 3 funtamental electronics.pptx
tryanothert7
 
PDF
Traditional Exams vs Continuous Assessment in Boarding Schools.pdf
The Asian School
 
PDF
67243-Cooling and Heating & Calculation.pdf
DHAKA POLYTECHNIC
 
PPTX
IoT_Smart_Agriculture_Presentations.pptx
poojakumari696707
 
PPTX
Victory Precisions_Supplier Profile.pptx
victoryprecisions199
 
PDF
EVS+PRESENTATIONS EVS+PRESENTATIONS like
saiyedaqib429
 
PPTX
22PCOAM21 Session 2 Understanding Data Source.pptx
Guru Nanak Technical Institutions
 
PPTX
Inventory management chapter in automation and robotics.
atisht0104
 
PDF
오픈소스 LLM, vLLM으로 Production까지 (Instruct.KR Summer Meetup, 2025)
Hyogeun Oh
 
PDF
Principles of Food Science and Nutritions
Dr. Yogesh Kumar Kosariya
 
PPTX
MSME 4.0 Template idea hackathon pdf to understand
alaudeenaarish
 
PPTX
22PCOAM21 Session 1 Data Management.pptx
Guru Nanak Technical Institutions
 
PDF
Software Testing Tools - names and explanation
shruti533256
 
PDF
LEAP-1B presedntation xxxxxxxxxxxxxxxxxxxxxxxxxxxxx
hatem173148
 
PPT
Lecture in network security and mobile computing
AbdullahOmar704132
 
SAR - EEEfdfdsdasdsdasdasdasdasdasdasdasda.docx
Kanimozhi676285
 
Queuing formulas to evaluate throughputs and servers
gptshubham
 
Civil Engineering Practices_BY Sh.JP Mishra 23.09.pptx
bineetmishra1990
 
The Effect of Artifact Removal from EEG Signals on the Detection of Epileptic...
Partho Prosad
 
Ppt for engineering students application on field effect
lakshmi.ec
 
easa module 3 funtamental electronics.pptx
tryanothert7
 
Traditional Exams vs Continuous Assessment in Boarding Schools.pdf
The Asian School
 
67243-Cooling and Heating & Calculation.pdf
DHAKA POLYTECHNIC
 
IoT_Smart_Agriculture_Presentations.pptx
poojakumari696707
 
Victory Precisions_Supplier Profile.pptx
victoryprecisions199
 
EVS+PRESENTATIONS EVS+PRESENTATIONS like
saiyedaqib429
 
22PCOAM21 Session 2 Understanding Data Source.pptx
Guru Nanak Technical Institutions
 
Inventory management chapter in automation and robotics.
atisht0104
 
오픈소스 LLM, vLLM으로 Production까지 (Instruct.KR Summer Meetup, 2025)
Hyogeun Oh
 
Principles of Food Science and Nutritions
Dr. Yogesh Kumar Kosariya
 
MSME 4.0 Template idea hackathon pdf to understand
alaudeenaarish
 
22PCOAM21 Session 1 Data Management.pptx
Guru Nanak Technical Institutions
 
Software Testing Tools - names and explanation
shruti533256
 
LEAP-1B presedntation xxxxxxxxxxxxxxxxxxxxxxxxxxxxx
hatem173148
 
Lecture in network security and mobile computing
AbdullahOmar704132
 

The Point of Vue - Intro to Vue.js