SlideShare ist ein Scribd-Unternehmen logo
1 von 45
Downloaden Sie, um offline zu lesen
ROOM WITH A VUE
INTRODUCTION TO VUE.JS
December 8, 2017
ROOM WITH A VUE
ABOUT ME
▸ Me: Zachary Klein
▸ Based in St Louis, MO
▸ Web dev since 2010
▸ Work for Object Computing, Inc
▸ Specialize in Grails & frontend
development
ROOM WITH A VUE
ABOUT US
▸ My company: Object Computing,
Inc
▸ Based in St Louis, MO
▸ Consulting and training
provider (24+ years experience)
▸ Corporate sponsor to the Grails
framework and Groovy
language
▸ https://objectcomputing.com
ROOM WITH A VUE
ABOUT US
▸ Grails: A dynamic, flexible web application framework
▸ Built on top of Spring Boot
▸ First-class support for REST APIs
▸ Profiles for building applications using React,
Angular, Webpack, and RESTful backends
▸ Powerful persistence layer with GORM - supports
Hibernate, MongoDb, Neo4J, GraphQL, and more
▸ Rich plugin ecosystem: 200+ plugins and growing
▸ Active community and commercial support available.
▸ https://grails.org
SHIELDS UP - SECURING REACT APPS
HTTP://START.GRAILS.ORG
ROOM WITH A VUE
HTTP://GUIDES.GRAILS.ORG
ROOM WITH A VUE
ROOM WITH A VUE
ABOUT US
▸ You:
▸?
ROOM WITH A VUE
OVERVIEW
▸ Introduction to Vue.js
▸ Building an app
▸ Ecosystem
▸ Comparison
ROOM WITH A VUE
INTRODUCTION TO VUE.JS
▸ Seriously, another JavaScript framework?
▸ What’s special about Vue?
▸ Trends and stars
ROOM WITH A VUE
http://www.timqian.com/star-history/#facebook/react&angular/angular&vuejs/vue
ROOM WITH A VUE
WHAT IS VUE?
▸ Released in 2014
▸ Current major release (2.x) in 2016
▸ Evan You (inventor & core developer) comes from a
Google/Angular background
▸ Balances between the power/complexity of Angular and
the simplicity/focus of React
ROOM WITH A VUE
WHAT IS VUE?
▸ Small, focused view library
▸ Performant*
▸ Full-featured API
▸ Mature* ecosystem
▸ Powerful devtools
▸ Active community
ROOM WITH A VUE
GETTING STARTED
▸ Install from NPM
▸ Install vue-cli
▸ vue init [template] my-app
▸ Multiple templates available - simple, webpack-simple,
& webpack
ROOM WITH A VUE
<script src="https://unpkg.com/vue"></script>
<div id=“app”>
{{ text }}
</div>
<script>
var app = new Vue({
el: '#app',
data: {
text: ‘Hello World!’
}
})
</script>
GETTING STARTED
ROOM WITH A VUE
THE VUE INSTANCE
▸ Ground zero for a Vue.js app
▸ Accepts an object containing the Vue Instance definition
▸ Most definitions shared between instance and
components
new Vue({
el: ‘#app’,
data: {...},
computed: {...},
methods: {...},
template: '<App/>'
})
export default {
name: 'component',
data () { return {...} },
name: 'component',
methods: {...}
}
Vue ComponentVue Instance
ROOM WITH A VUE
THE VUE INSTANCE
▸ Element
▸ Specifies the DOM element where the app will be
rendered
new Vue({
el: ‘#app’
})
<div id="app"></div>
ROOM WITH A VUE
THE VUE INSTANCE
▸ Data
▸ An object describing the state of the app/component
▸ Properties are subject to reactive rendering within the
app/component (one-way & two-way)
▸ New properties can be added, but will not be subject to
reactive behavior
▸ Components must use a data() function that returns state
ROOM WITH A VUE
THE VUE INSTANCE
▸ Data
new Vue({
data: {
myValue: 3,
myObject: {
prop: 'abc'
}
}
})
export default {
data () {
return {
myValue: 3,
myObject: {
prop: 'abc'
}
}
}
Vue ComponentVue Instance
ROOM WITH A VUE
THE VUE INSTANCE
▸ Methods
▸ Arbitrary functions
▸ Can access/manipulate data
▸ Can be called from templates, other methods
methods: {
toggleLinks: function () {
this.showLinks = !this.showLinks
}
},
ROOM WITH A VUE
THE VUE INSTANCE
▸ Computed Properties
▸ Functions that return dynamic values
▸ Accessed from templates & methods as state properties
ROOM WITH A VUE
THE VUE INSTANCE
▸ Lifecycle Hooks
▸ Functions that are called at specific points in the app/
component lifecycle
created: function () {
this.$http.get(`${this.$data.serverURL}/application`).then(response => {
this.$data.serverInfo = response.body
})
},
ROOM WITH A VUE
ROOM WITH A VUE
ROOM WITH A VUE
TEMPLATES
▸ HTML based Templating syntax
▸ “Mustache” {{}} syntax for string interpolation and dynamic variables
▸ Directives
▸ prefixed with “v-“
▸ accept arguments separated by “:”
▸ support modifiers prefixed with “.”
▸ Rendered via a virtual DOM, for efficient updates
ROOM WITH A VUE
TEMPLATES
<template>
<div class="form">
<div class="title cell">
<label>Title</label>
<input ref="bookTitle" v-model="book.title" type="text"/>
</div>
<div class="pages cell">
<label>Pages</label>
<input v-model="book.pages" type="text"/>
</div>
<div class="author cell">
<label>Author</label>
<select v-model="book.author">
<option disabled selected value="">Choose Author</option>
<option v-if="author !== null"
v-bind:value="{ id: author.id }"
v-for="author in authors">{{author.name}}</option>
</select>
</div>
<div class="save cell">
<button @click="submitNewBook()" >Add Book</button>
</div>
</div>
</template>
ROOM WITH A VUE
COMPONENTS
▸ Nested component hierarchy
▸ Each component renders either a template or returns
createElement() calls (JSX is supported)
▸ Components typically defined in single files with
<template>, <script>, and <style> sections
ROOM WITH A VUE
ECOSYSTEM
▸ State Management - Vuex
▸ Routing - Vue Router
▸ UI Libraries - VueStrap (3), BootstrapVue (4) & VueMaterial
ROOM WITH A VUE
ECOSYSTEM
▸ State Management - Vuex
▸ Routing - Vue Router
▸ UI Libraries
▸ VueStrap (Bootstrap 3)
▸ BootstrapVue (Bootstrap 4)
▸ VueMaterial (Material UI)
ROOM WITH A VUE
VUEX
▸ State-management library, a la Redux
▸ Provides conventions/constraints around application state
▸ Single store
▸ Data access via “getters”
▸ Data modifications via “mutations”
▸ Asynchronous work done in “actions”
ROOM WITH A VUE
VUEX
▸ The Store
▸ Top-level object: new Vuex.Store()
▸ Receives an object of properties, similar to
Vue.Instance definition
▸ Single state tree (can be divided into modules)
▸ Store accessed by components via computed properties
▸ Store can only be modified by mutations
ROOM WITH A VUE
VUEX const store = new Vuex.Store({
state: {
authors: [],
books: []
},
mutations: {
addBook (state, payload) {
state.books.push(payload.book)
},
addAuthor (state, payload) {
console.log('adding author...')
state.authors.push(payload.author)
},
removeBook (state, payload) {
state.books = state.books.filter(b => b.id !== payload.id)
},
removeAuthor (state, payload) {
state.books = state.authors.filter(b => b.id !== payload.id)
},
setBooks (state, payload) {
state.books = payload.books
},
setAuthors (state, payload) {
state.authors = payload.authors
}
}
})
ROOM WITH A VUE
VUEX
▸ Getters
▸ “Computed properties” for store values
▸ Not needed for direct access to store properties
▸ Useful for filtering - `completedTodos`, `expiredSubs`, etc
getters: {
doneTodos: state => {
return state.todos.filter(todo => todo.done)
}
}
ROOM WITH A VUE
VUEX
▸ Mutations
▸ Analogous to “events” - has a type & handler function
▸ Not called directly - instead “committed” to the store
▸ Can accept a “payload” argument (usually an object)
▸ Synchronous transactions only
mutations: {
addBook (state, payload) {
state.books.push(payload.book)
}
}
ROOM WITH A VUE
VUEX
▸ Actions
▸ Store functions that commit mutations
▸ Are “dispatched” from the store
▸ Can perform asynchronous work (REST calls, etc)
▸ Can dispatch other actions
▸ Receive a “context” arg with access to store variables/
methods
ROOM WITH A VUE
VUEX
▸ Actions
actions: {
loadAuthors: function ({commit, state}) {
fetch(`${state.serverURL}/author`)
.then(r => r.json())
.then(json => commit('setAuthors', {authors: json}))
.catch(e => console.warn(e))
}
}
ROOM WITH A VUE
VUE-ROUTER
▸ First-class Router for Vue.js applications
▸ Similar conventions to React-Router < v4
▸ Modes for hash (default) & browser history
▸ Redirects, URL params, wildcards, oh my!
ROOM WITH A VUE
COMPARE AND CONTRAST - ANGULAR
▸ A cleaner, simpler way to build apps
▸ Similar concepts/syntax: directives, templates, v-model
▸ More understandable, readable code
▸ Less code
▸ A rich, featureful API that doesn’t make you do everything
with plain JavaScript
▸ Not a framework - you’ll still need to add packages
ROOM WITH A VUE
COMPARE AND CONTRAST - REACT
▸ Adding some magic back in to JavaScript
▸ Similar concepts/syntax: components, virtual DOM,
lifecycle methods
▸ Supports JSX*
▸ Less code… sometimes
▸ Less opaque than Angular - but not “pure” JS
ROOM WITH A VUE
SUMMARY
▸ Vue.js is not “just” another JavaScript framework
▸ Aims for balance between rich, developer-friendly features
and clean, understandable code
▸ Community is vibrant and engaged, and shows every sign
of being in this for the long haul
▸ Vue.js is definitely worth learning, either as a first-timer’s
JavaScript framework or for developers looking for a fresh
view of SPAs
ROOM WITH A VUE
LINKS
▸ http://vuejs.org (links to Vuex/Vue-Router)
▸ https://github.com/vuejs/awesome-vue
▸ https://medium.com/unicorn-supplies/angular-vs-react-vs-
vue-a-2017-comparison-c5c52d620176
▸ https://medium.freecodecamp.org/between-the-wires-an-
interview-with-vue-js-creator-evan-you-e383cbf57cc4
ROOM WITH A VUE
LINKS
▸ http://vuejs.org (links to Vuex/Vue-Router)
▸ https://github.com/vuejs/awesome-vue
▸ https://medium.com/unicorn-supplies/angular-vs-react-vs-
vue-a-2017-comparison-c5c52d620176
▸ https://medium.freecodecamp.org/between-the-wires-an-
interview-with-vue-js-creator-evan-you-e383cbf57cc4
ROOM WITH A VUE
LINKS
▸ http://vuejs.org (links to Vuex/Vue-Router)
▸ https://github.com/vuejs/awesome-vue
▸ https://medium.com/unicorn-supplies/angular-vs-react-vs-
vue-a-2017-comparison-c5c52d620176
▸ https://medium.freecodecamp.org/between-the-wires-an-
interview-with-vue-js-creator-evan-you-e383cbf57cc4
THANK YOU
Twitter: @ZacharyAKlein. Github: @ZacharyKlein. Email: zak@silver-chalice.com

Weitere ähnliche Inhalte

Was ist angesagt?

An introduction to Vue.js
An introduction to Vue.jsAn introduction to Vue.js
An introduction to Vue.jsPagepro
 
Drupal point of vue
Drupal point of vueDrupal point of vue
Drupal point of vueDavid Ličen
 
introduction to Vue.js 3
introduction to Vue.js 3 introduction to Vue.js 3
introduction to Vue.js 3 ArezooKmn
 
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 VueJSdanpastori
 
An Introduction to Vuejs
An Introduction to VuejsAn Introduction to Vuejs
An Introduction to VuejsPaddy Lock
 
Vuejs for Angular developers
Vuejs for Angular developersVuejs for Angular developers
Vuejs for Angular developersMikhail Kuznetcov
 
Introduction to VueJS & Vuex
Introduction to VueJS & VuexIntroduction to VueJS & Vuex
Introduction to VueJS & VuexBernd Alter
 
Vue.js is boring - and that's a good thing
Vue.js is boring - and that's a good thingVue.js is boring - and that's a good thing
Vue.js is boring - and that's a good thingJoonas Lehtonen
 
Basics of Vue.js 2019
Basics of Vue.js 2019Basics of Vue.js 2019
Basics of Vue.js 2019Paul Bele
 
Vuejs getting-started - Extended Version
Vuejs getting-started - Extended VersionVuejs getting-started - Extended Version
Vuejs getting-started - Extended VersionMurat Doğan
 
Nuxt.JS Introdruction
Nuxt.JS IntrodructionNuxt.JS Introdruction
Nuxt.JS IntrodructionDavid Ličen
 
WordPress 2017 with VueJS and GraphQL
WordPress 2017 with VueJS and GraphQLWordPress 2017 with VueJS and GraphQL
WordPress 2017 with VueJS and GraphQLhouzman
 
Intro to vue.js
Intro to vue.jsIntro to vue.js
Intro to vue.jsTechMagic
 

Was ist angesagt? (20)

An introduction to Vue.js
An introduction to Vue.jsAn introduction to Vue.js
An introduction to Vue.js
 
Drupal point of vue
Drupal point of vueDrupal point of vue
Drupal point of vue
 
Love at first Vue
Love at first VueLove at first Vue
Love at first Vue
 
introduction to Vue.js 3
introduction to Vue.js 3 introduction to Vue.js 3
introduction to Vue.js 3
 
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
 
Vue presentation
Vue presentationVue presentation
Vue presentation
 
Why Vue.js?
Why Vue.js?Why Vue.js?
Why Vue.js?
 
Meet VueJs
Meet VueJsMeet VueJs
Meet VueJs
 
An Introduction to Vuejs
An Introduction to VuejsAn Introduction to Vuejs
An Introduction to Vuejs
 
Vuejs for Angular developers
Vuejs for Angular developersVuejs for Angular developers
Vuejs for Angular developers
 
Intro to Vue
Intro to Vue Intro to Vue
Intro to Vue
 
Vue business first
Vue business firstVue business first
Vue business first
 
Introduction to VueJS & Vuex
Introduction to VueJS & VuexIntroduction to VueJS & Vuex
Introduction to VueJS & Vuex
 
Vue.js is boring - and that's a good thing
Vue.js is boring - and that's a good thingVue.js is boring - and that's a good thing
Vue.js is boring - and that's a good thing
 
Basics of Vue.js 2019
Basics of Vue.js 2019Basics of Vue.js 2019
Basics of Vue.js 2019
 
Vuejs getting-started - Extended Version
Vuejs getting-started - Extended VersionVuejs getting-started - Extended Version
Vuejs getting-started - Extended Version
 
Nuxt.JS Introdruction
Nuxt.JS IntrodructionNuxt.JS Introdruction
Nuxt.JS Introdruction
 
WordPress 2017 with VueJS and GraphQL
WordPress 2017 with VueJS and GraphQLWordPress 2017 with VueJS and GraphQL
WordPress 2017 with VueJS and GraphQL
 
Vuex
VuexVuex
Vuex
 
Intro to vue.js
Intro to vue.jsIntro to vue.js
Intro to vue.js
 

Ähnlich wie Room with a Vue - Introduction to Vue.js

VueJS Best Practices
VueJS Best PracticesVueJS Best Practices
VueJS Best PracticesFatih Acet
 
Java Web Programming on Google Cloud Platform [1/3] : Google App Engine
Java Web Programming on Google Cloud Platform [1/3] : Google App EngineJava Web Programming on Google Cloud Platform [1/3] : Google App Engine
Java Web Programming on Google Cloud Platform [1/3] : Google App EngineIMC Institute
 
An approach to responsive, realtime with Backbone.js and WebSockets
An approach to responsive, realtime with Backbone.js and WebSocketsAn approach to responsive, realtime with Backbone.js and WebSockets
An approach to responsive, realtime with Backbone.js and WebSocketsAndrei Sebastian Cîmpean
 
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 + TypeScriptKaty Slemon
 
Creating a full stack web app with python, npm, webpack and react
Creating a full stack web app with python, npm, webpack and reactCreating a full stack web app with python, npm, webpack and react
Creating a full stack web app with python, npm, webpack and reactAngela Kristine Juvet Branaes
 
WordPress as the Backbone(.js)
WordPress as the Backbone(.js)WordPress as the Backbone(.js)
WordPress as the Backbone(.js)Beau Lebens
 
How to Webpack your Django!
How to Webpack your Django!How to Webpack your Django!
How to Webpack your Django!David Gibbons
 
Javascript frameworks: Backbone.js
Javascript frameworks: Backbone.jsJavascript frameworks: Backbone.js
Javascript frameworks: Backbone.jsSoós Gábor
 
Serverless archtiectures
Serverless archtiecturesServerless archtiectures
Serverless archtiecturesIegor Fadieiev
 
Web Components Everywhere
Web Components EverywhereWeb Components Everywhere
Web Components EverywhereIlia Idakiev
 
Workshop: Building Vaadin add-ons
Workshop: Building Vaadin add-onsWorkshop: Building Vaadin add-ons
Workshop: Building Vaadin add-onsSami Ekblad
 
Practical AngularJS
Practical AngularJSPractical AngularJS
Practical AngularJSWei Ru
 
Overview of The Scala Based Lift Web Framework
Overview of The Scala Based Lift Web FrameworkOverview of The Scala Based Lift Web Framework
Overview of The Scala Based Lift Web FrameworkIndicThreads
 
Scala based Lift Framework
Scala based Lift FrameworkScala based Lift Framework
Scala based Lift Frameworkvhazrati
 
OpenStack Horizon: Controlling the Cloud using Django
OpenStack Horizon: Controlling the Cloud using DjangoOpenStack Horizon: Controlling the Cloud using Django
OpenStack Horizon: Controlling the Cloud using DjangoDavid Lapsley
 
20141001 delapsley-oc-openstack-final
20141001 delapsley-oc-openstack-final20141001 delapsley-oc-openstack-final
20141001 delapsley-oc-openstack-finalDavid Lapsley
 
Universal JS Applications with React
Universal JS Applications with ReactUniversal JS Applications with React
Universal JS Applications with ReactThanh Trần Trọng
 

Ähnlich wie Room with a Vue - Introduction to Vue.js (20)

VueJS Best Practices
VueJS Best PracticesVueJS Best Practices
VueJS Best Practices
 
Java Web Programming on Google Cloud Platform [1/3] : Google App Engine
Java Web Programming on Google Cloud Platform [1/3] : Google App EngineJava Web Programming on Google Cloud Platform [1/3] : Google App Engine
Java Web Programming on Google Cloud Platform [1/3] : Google App Engine
 
An approach to responsive, realtime with Backbone.js and WebSockets
An approach to responsive, realtime with Backbone.js and WebSocketsAn approach to responsive, realtime with Backbone.js and WebSockets
An approach to responsive, realtime with Backbone.js and WebSockets
 
Google App Engine
Google App EngineGoogle App Engine
Google App Engine
 
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
 
Creating a full stack web app with python, npm, webpack and react
Creating a full stack web app with python, npm, webpack and reactCreating a full stack web app with python, npm, webpack and react
Creating a full stack web app with python, npm, webpack and react
 
WordPress as the Backbone(.js)
WordPress as the Backbone(.js)WordPress as the Backbone(.js)
WordPress as the Backbone(.js)
 
How to Webpack your Django!
How to Webpack your Django!How to Webpack your Django!
How to Webpack your Django!
 
Javascript frameworks: Backbone.js
Javascript frameworks: Backbone.jsJavascript frameworks: Backbone.js
Javascript frameworks: Backbone.js
 
Serverless archtiectures
Serverless archtiecturesServerless archtiectures
Serverless archtiectures
 
Web Components Everywhere
Web Components EverywhereWeb Components Everywhere
Web Components Everywhere
 
Google app engine by example
Google app engine by exampleGoogle app engine by example
Google app engine by example
 
Workshop: Building Vaadin add-ons
Workshop: Building Vaadin add-onsWorkshop: Building Vaadin add-ons
Workshop: Building Vaadin add-ons
 
Practical AngularJS
Practical AngularJSPractical AngularJS
Practical AngularJS
 
Overview Of Lift Framework
Overview Of Lift FrameworkOverview Of Lift Framework
Overview Of Lift Framework
 
Overview of The Scala Based Lift Web Framework
Overview of The Scala Based Lift Web FrameworkOverview of The Scala Based Lift Web Framework
Overview of The Scala Based Lift Web Framework
 
Scala based Lift Framework
Scala based Lift FrameworkScala based Lift Framework
Scala based Lift Framework
 
OpenStack Horizon: Controlling the Cloud using Django
OpenStack Horizon: Controlling the Cloud using DjangoOpenStack Horizon: Controlling the Cloud using Django
OpenStack Horizon: Controlling the Cloud using Django
 
20141001 delapsley-oc-openstack-final
20141001 delapsley-oc-openstack-final20141001 delapsley-oc-openstack-final
20141001 delapsley-oc-openstack-final
 
Universal JS Applications with React
Universal JS Applications with ReactUniversal JS Applications with React
Universal JS Applications with React
 

Mehr von Zachary Klein

Native Cloud-Native: Building Agile Microservices with the Micronaut Framework
Native Cloud-Native: Building Agile Microservices with the Micronaut FrameworkNative Cloud-Native: Building Agile Microservices with the Micronaut Framework
Native Cloud-Native: Building Agile Microservices with the Micronaut FrameworkZachary Klein
 
Groovy-Powered Microservices with Micronaut
Groovy-Powered Microservices with MicronautGroovy-Powered Microservices with Micronaut
Groovy-Powered Microservices with MicronautZachary Klein
 
Micronaut: Changing the Micro Future
Micronaut: Changing the Micro FutureMicronaut: Changing the Micro Future
Micronaut: Changing the Micro FutureZachary Klein
 
Grails 4: Upgrade your Game!
Grails 4: Upgrade your Game!Grails 4: Upgrade your Game!
Grails 4: Upgrade your Game!Zachary Klein
 
Getting Groovy with JHipster and Micronaut
Getting Groovy with JHipster and MicronautGetting Groovy with JHipster and Micronaut
Getting Groovy with JHipster and MicronautZachary Klein
 
Groovy for Java Devs
Groovy for Java DevsGroovy for Java Devs
Groovy for Java DevsZachary Klein
 
Micronaut For Single Page Apps
Micronaut For Single Page AppsMicronaut For Single Page Apps
Micronaut For Single Page AppsZachary Klein
 
Shields Up! Securing React Apps
Shields Up! Securing React AppsShields Up! Securing React Apps
Shields Up! Securing React AppsZachary Klein
 
Using React with Grails 3
Using React with Grails 3Using React with Grails 3
Using React with Grails 3Zachary Klein
 

Mehr von Zachary Klein (10)

Native Cloud-Native: Building Agile Microservices with the Micronaut Framework
Native Cloud-Native: Building Agile Microservices with the Micronaut FrameworkNative Cloud-Native: Building Agile Microservices with the Micronaut Framework
Native Cloud-Native: Building Agile Microservices with the Micronaut Framework
 
Groovy-Powered Microservices with Micronaut
Groovy-Powered Microservices with MicronautGroovy-Powered Microservices with Micronaut
Groovy-Powered Microservices with Micronaut
 
Micronaut: Changing the Micro Future
Micronaut: Changing the Micro FutureMicronaut: Changing the Micro Future
Micronaut: Changing the Micro Future
 
Grails 4: Upgrade your Game!
Grails 4: Upgrade your Game!Grails 4: Upgrade your Game!
Grails 4: Upgrade your Game!
 
Getting Groovy with JHipster and Micronaut
Getting Groovy with JHipster and MicronautGetting Groovy with JHipster and Micronaut
Getting Groovy with JHipster and Micronaut
 
Micronaut Launchpad
Micronaut LaunchpadMicronaut Launchpad
Micronaut Launchpad
 
Groovy for Java Devs
Groovy for Java DevsGroovy for Java Devs
Groovy for Java Devs
 
Micronaut For Single Page Apps
Micronaut For Single Page AppsMicronaut For Single Page Apps
Micronaut For Single Page Apps
 
Shields Up! Securing React Apps
Shields Up! Securing React AppsShields Up! Securing React Apps
Shields Up! Securing React Apps
 
Using React with Grails 3
Using React with Grails 3Using React with Grails 3
Using React with Grails 3
 

Kürzlich hochgeladen

%+27788225528 love spells in Colorado Springs Psychic Readings, Attraction sp...
%+27788225528 love spells in Colorado Springs Psychic Readings, Attraction sp...%+27788225528 love spells in Colorado Springs Psychic Readings, Attraction sp...
%+27788225528 love spells in Colorado Springs Psychic Readings, Attraction sp...masabamasaba
 
TECUNIQUE: Success Stories: IT Service provider
TECUNIQUE: Success Stories: IT Service providerTECUNIQUE: Success Stories: IT Service provider
TECUNIQUE: Success Stories: IT Service providermohitmore19
 
Architecture decision records - How not to get lost in the past
Architecture decision records - How not to get lost in the pastArchitecture decision records - How not to get lost in the past
Architecture decision records - How not to get lost in the pastPapp Krisztián
 
Shapes for Sharing between Graph Data Spaces - and Epistemic Querying of RDF-...
Shapes for Sharing between Graph Data Spaces - and Epistemic Querying of RDF-...Shapes for Sharing between Graph Data Spaces - and Epistemic Querying of RDF-...
Shapes for Sharing between Graph Data Spaces - and Epistemic Querying of RDF-...Steffen Staab
 
%+27788225528 love spells in Vancouver Psychic Readings, Attraction spells,Br...
%+27788225528 love spells in Vancouver Psychic Readings, Attraction spells,Br...%+27788225528 love spells in Vancouver Psychic Readings, Attraction spells,Br...
%+27788225528 love spells in Vancouver Psychic Readings, Attraction spells,Br...masabamasaba
 
%+27788225528 love spells in Boston Psychic Readings, Attraction spells,Bring...
%+27788225528 love spells in Boston Psychic Readings, Attraction spells,Bring...%+27788225528 love spells in Boston Psychic Readings, Attraction spells,Bring...
%+27788225528 love spells in Boston Psychic Readings, Attraction spells,Bring...masabamasaba
 
Software Quality Assurance Interview Questions
Software Quality Assurance Interview QuestionsSoftware Quality Assurance Interview Questions
Software Quality Assurance Interview QuestionsArshad QA
 
%in kempton park+277-882-255-28 abortion pills for sale in kempton park
%in kempton park+277-882-255-28 abortion pills for sale in kempton park %in kempton park+277-882-255-28 abortion pills for sale in kempton park
%in kempton park+277-882-255-28 abortion pills for sale in kempton park masabamasaba
 
Announcing Codolex 2.0 from GDK Software
Announcing Codolex 2.0 from GDK SoftwareAnnouncing Codolex 2.0 from GDK Software
Announcing Codolex 2.0 from GDK SoftwareJim McKeeth
 
%in Lydenburg+277-882-255-28 abortion pills for sale in Lydenburg
%in Lydenburg+277-882-255-28 abortion pills for sale in Lydenburg%in Lydenburg+277-882-255-28 abortion pills for sale in Lydenburg
%in Lydenburg+277-882-255-28 abortion pills for sale in Lydenburgmasabamasaba
 
VTU technical seminar 8Th Sem on Scikit-learn
VTU technical seminar 8Th Sem on Scikit-learnVTU technical seminar 8Th Sem on Scikit-learn
VTU technical seminar 8Th Sem on Scikit-learnAmarnathKambale
 
Unlocking the Future of AI Agents with Large Language Models
Unlocking the Future of AI Agents with Large Language ModelsUnlocking the Future of AI Agents with Large Language Models
Unlocking the Future of AI Agents with Large Language Modelsaagamshah0812
 
%in Harare+277-882-255-28 abortion pills for sale in Harare
%in Harare+277-882-255-28 abortion pills for sale in Harare%in Harare+277-882-255-28 abortion pills for sale in Harare
%in Harare+277-882-255-28 abortion pills for sale in Hararemasabamasaba
 
call girls in Vaishali (Ghaziabad) 🔝 >༒8448380779 🔝 genuine Escort Service 🔝✔️✔️
call girls in Vaishali (Ghaziabad) 🔝 >༒8448380779 🔝 genuine Escort Service 🔝✔️✔️call girls in Vaishali (Ghaziabad) 🔝 >༒8448380779 🔝 genuine Escort Service 🔝✔️✔️
call girls in Vaishali (Ghaziabad) 🔝 >༒8448380779 🔝 genuine Escort Service 🔝✔️✔️Delhi Call girls
 
%in kaalfontein+277-882-255-28 abortion pills for sale in kaalfontein
%in kaalfontein+277-882-255-28 abortion pills for sale in kaalfontein%in kaalfontein+277-882-255-28 abortion pills for sale in kaalfontein
%in kaalfontein+277-882-255-28 abortion pills for sale in kaalfonteinmasabamasaba
 
Crypto Cloud Review - How To Earn Up To $500 Per DAY Of Bitcoin 100% On AutoP...
Crypto Cloud Review - How To Earn Up To $500 Per DAY Of Bitcoin 100% On AutoP...Crypto Cloud Review - How To Earn Up To $500 Per DAY Of Bitcoin 100% On AutoP...
Crypto Cloud Review - How To Earn Up To $500 Per DAY Of Bitcoin 100% On AutoP...SelfMade bd
 
Introducing Microsoft’s new Enterprise Work Management (EWM) Solution
Introducing Microsoft’s new Enterprise Work Management (EWM) SolutionIntroducing Microsoft’s new Enterprise Work Management (EWM) Solution
Introducing Microsoft’s new Enterprise Work Management (EWM) SolutionOnePlan Solutions
 
Generic or specific? Making sensible software design decisions
Generic or specific? Making sensible software design decisionsGeneric or specific? Making sensible software design decisions
Generic or specific? Making sensible software design decisionsBert Jan Schrijver
 
%in tembisa+277-882-255-28 abortion pills for sale in tembisa
%in tembisa+277-882-255-28 abortion pills for sale in tembisa%in tembisa+277-882-255-28 abortion pills for sale in tembisa
%in tembisa+277-882-255-28 abortion pills for sale in tembisamasabamasaba
 
%in Hazyview+277-882-255-28 abortion pills for sale in Hazyview
%in Hazyview+277-882-255-28 abortion pills for sale in Hazyview%in Hazyview+277-882-255-28 abortion pills for sale in Hazyview
%in Hazyview+277-882-255-28 abortion pills for sale in Hazyviewmasabamasaba
 

Kürzlich hochgeladen (20)

%+27788225528 love spells in Colorado Springs Psychic Readings, Attraction sp...
%+27788225528 love spells in Colorado Springs Psychic Readings, Attraction sp...%+27788225528 love spells in Colorado Springs Psychic Readings, Attraction sp...
%+27788225528 love spells in Colorado Springs Psychic Readings, Attraction sp...
 
TECUNIQUE: Success Stories: IT Service provider
TECUNIQUE: Success Stories: IT Service providerTECUNIQUE: Success Stories: IT Service provider
TECUNIQUE: Success Stories: IT Service provider
 
Architecture decision records - How not to get lost in the past
Architecture decision records - How not to get lost in the pastArchitecture decision records - How not to get lost in the past
Architecture decision records - How not to get lost in the past
 
Shapes for Sharing between Graph Data Spaces - and Epistemic Querying of RDF-...
Shapes for Sharing between Graph Data Spaces - and Epistemic Querying of RDF-...Shapes for Sharing between Graph Data Spaces - and Epistemic Querying of RDF-...
Shapes for Sharing between Graph Data Spaces - and Epistemic Querying of RDF-...
 
%+27788225528 love spells in Vancouver Psychic Readings, Attraction spells,Br...
%+27788225528 love spells in Vancouver Psychic Readings, Attraction spells,Br...%+27788225528 love spells in Vancouver Psychic Readings, Attraction spells,Br...
%+27788225528 love spells in Vancouver Psychic Readings, Attraction spells,Br...
 
%+27788225528 love spells in Boston Psychic Readings, Attraction spells,Bring...
%+27788225528 love spells in Boston Psychic Readings, Attraction spells,Bring...%+27788225528 love spells in Boston Psychic Readings, Attraction spells,Bring...
%+27788225528 love spells in Boston Psychic Readings, Attraction spells,Bring...
 
Software Quality Assurance Interview Questions
Software Quality Assurance Interview QuestionsSoftware Quality Assurance Interview Questions
Software Quality Assurance Interview Questions
 
%in kempton park+277-882-255-28 abortion pills for sale in kempton park
%in kempton park+277-882-255-28 abortion pills for sale in kempton park %in kempton park+277-882-255-28 abortion pills for sale in kempton park
%in kempton park+277-882-255-28 abortion pills for sale in kempton park
 
Announcing Codolex 2.0 from GDK Software
Announcing Codolex 2.0 from GDK SoftwareAnnouncing Codolex 2.0 from GDK Software
Announcing Codolex 2.0 from GDK Software
 
%in Lydenburg+277-882-255-28 abortion pills for sale in Lydenburg
%in Lydenburg+277-882-255-28 abortion pills for sale in Lydenburg%in Lydenburg+277-882-255-28 abortion pills for sale in Lydenburg
%in Lydenburg+277-882-255-28 abortion pills for sale in Lydenburg
 
VTU technical seminar 8Th Sem on Scikit-learn
VTU technical seminar 8Th Sem on Scikit-learnVTU technical seminar 8Th Sem on Scikit-learn
VTU technical seminar 8Th Sem on Scikit-learn
 
Unlocking the Future of AI Agents with Large Language Models
Unlocking the Future of AI Agents with Large Language ModelsUnlocking the Future of AI Agents with Large Language Models
Unlocking the Future of AI Agents with Large Language Models
 
%in Harare+277-882-255-28 abortion pills for sale in Harare
%in Harare+277-882-255-28 abortion pills for sale in Harare%in Harare+277-882-255-28 abortion pills for sale in Harare
%in Harare+277-882-255-28 abortion pills for sale in Harare
 
call girls in Vaishali (Ghaziabad) 🔝 >༒8448380779 🔝 genuine Escort Service 🔝✔️✔️
call girls in Vaishali (Ghaziabad) 🔝 >༒8448380779 🔝 genuine Escort Service 🔝✔️✔️call girls in Vaishali (Ghaziabad) 🔝 >༒8448380779 🔝 genuine Escort Service 🔝✔️✔️
call girls in Vaishali (Ghaziabad) 🔝 >༒8448380779 🔝 genuine Escort Service 🔝✔️✔️
 
%in kaalfontein+277-882-255-28 abortion pills for sale in kaalfontein
%in kaalfontein+277-882-255-28 abortion pills for sale in kaalfontein%in kaalfontein+277-882-255-28 abortion pills for sale in kaalfontein
%in kaalfontein+277-882-255-28 abortion pills for sale in kaalfontein
 
Crypto Cloud Review - How To Earn Up To $500 Per DAY Of Bitcoin 100% On AutoP...
Crypto Cloud Review - How To Earn Up To $500 Per DAY Of Bitcoin 100% On AutoP...Crypto Cloud Review - How To Earn Up To $500 Per DAY Of Bitcoin 100% On AutoP...
Crypto Cloud Review - How To Earn Up To $500 Per DAY Of Bitcoin 100% On AutoP...
 
Introducing Microsoft’s new Enterprise Work Management (EWM) Solution
Introducing Microsoft’s new Enterprise Work Management (EWM) SolutionIntroducing Microsoft’s new Enterprise Work Management (EWM) Solution
Introducing Microsoft’s new Enterprise Work Management (EWM) Solution
 
Generic or specific? Making sensible software design decisions
Generic or specific? Making sensible software design decisionsGeneric or specific? Making sensible software design decisions
Generic or specific? Making sensible software design decisions
 
%in tembisa+277-882-255-28 abortion pills for sale in tembisa
%in tembisa+277-882-255-28 abortion pills for sale in tembisa%in tembisa+277-882-255-28 abortion pills for sale in tembisa
%in tembisa+277-882-255-28 abortion pills for sale in tembisa
 
%in Hazyview+277-882-255-28 abortion pills for sale in Hazyview
%in Hazyview+277-882-255-28 abortion pills for sale in Hazyview%in Hazyview+277-882-255-28 abortion pills for sale in Hazyview
%in Hazyview+277-882-255-28 abortion pills for sale in Hazyview
 

Room with a Vue - Introduction to Vue.js

  • 1. ROOM WITH A VUE INTRODUCTION TO VUE.JS December 8, 2017
  • 2. ROOM WITH A VUE ABOUT ME ▸ Me: Zachary Klein ▸ Based in St Louis, MO ▸ Web dev since 2010 ▸ Work for Object Computing, Inc ▸ Specialize in Grails & frontend development
  • 3. ROOM WITH A VUE ABOUT US ▸ My company: Object Computing, Inc ▸ Based in St Louis, MO ▸ Consulting and training provider (24+ years experience) ▸ Corporate sponsor to the Grails framework and Groovy language ▸ https://objectcomputing.com
  • 4.
  • 5. ROOM WITH A VUE ABOUT US ▸ Grails: A dynamic, flexible web application framework ▸ Built on top of Spring Boot ▸ First-class support for REST APIs ▸ Profiles for building applications using React, Angular, Webpack, and RESTful backends ▸ Powerful persistence layer with GORM - supports Hibernate, MongoDb, Neo4J, GraphQL, and more ▸ Rich plugin ecosystem: 200+ plugins and growing ▸ Active community and commercial support available. ▸ https://grails.org
  • 6. SHIELDS UP - SECURING REACT APPS
  • 9. ROOM WITH A VUE ABOUT US ▸ You: ▸?
  • 10. ROOM WITH A VUE OVERVIEW ▸ Introduction to Vue.js ▸ Building an app ▸ Ecosystem ▸ Comparison
  • 11. ROOM WITH A VUE INTRODUCTION TO VUE.JS ▸ Seriously, another JavaScript framework? ▸ What’s special about Vue? ▸ Trends and stars
  • 12. ROOM WITH A VUE http://www.timqian.com/star-history/#facebook/react&angular/angular&vuejs/vue
  • 13. ROOM WITH A VUE WHAT IS VUE? ▸ Released in 2014 ▸ Current major release (2.x) in 2016 ▸ Evan You (inventor & core developer) comes from a Google/Angular background ▸ Balances between the power/complexity of Angular and the simplicity/focus of React
  • 14. ROOM WITH A VUE WHAT IS VUE? ▸ Small, focused view library ▸ Performant* ▸ Full-featured API ▸ Mature* ecosystem ▸ Powerful devtools ▸ Active community
  • 15. ROOM WITH A VUE GETTING STARTED ▸ Install from NPM ▸ Install vue-cli ▸ vue init [template] my-app ▸ Multiple templates available - simple, webpack-simple, & webpack
  • 16. ROOM WITH A VUE <script src="https://unpkg.com/vue"></script> <div id=“app”> {{ text }} </div> <script> var app = new Vue({ el: '#app', data: { text: ‘Hello World!’ } }) </script> GETTING STARTED
  • 17. ROOM WITH A VUE THE VUE INSTANCE ▸ Ground zero for a Vue.js app ▸ Accepts an object containing the Vue Instance definition ▸ Most definitions shared between instance and components new Vue({ el: ‘#app’, data: {...}, computed: {...}, methods: {...}, template: '<App/>' }) export default { name: 'component', data () { return {...} }, name: 'component', methods: {...} } Vue ComponentVue Instance
  • 18. ROOM WITH A VUE THE VUE INSTANCE ▸ Element ▸ Specifies the DOM element where the app will be rendered new Vue({ el: ‘#app’ }) <div id="app"></div>
  • 19. ROOM WITH A VUE THE VUE INSTANCE ▸ Data ▸ An object describing the state of the app/component ▸ Properties are subject to reactive rendering within the app/component (one-way & two-way) ▸ New properties can be added, but will not be subject to reactive behavior ▸ Components must use a data() function that returns state
  • 20. ROOM WITH A VUE THE VUE INSTANCE ▸ Data new Vue({ data: { myValue: 3, myObject: { prop: 'abc' } } }) export default { data () { return { myValue: 3, myObject: { prop: 'abc' } } } Vue ComponentVue Instance
  • 21. ROOM WITH A VUE THE VUE INSTANCE ▸ Methods ▸ Arbitrary functions ▸ Can access/manipulate data ▸ Can be called from templates, other methods methods: { toggleLinks: function () { this.showLinks = !this.showLinks } },
  • 22. ROOM WITH A VUE THE VUE INSTANCE ▸ Computed Properties ▸ Functions that return dynamic values ▸ Accessed from templates & methods as state properties
  • 23. ROOM WITH A VUE THE VUE INSTANCE ▸ Lifecycle Hooks ▸ Functions that are called at specific points in the app/ component lifecycle created: function () { this.$http.get(`${this.$data.serverURL}/application`).then(response => { this.$data.serverInfo = response.body }) },
  • 24. ROOM WITH A VUE
  • 25. ROOM WITH A VUE
  • 26. ROOM WITH A VUE TEMPLATES ▸ HTML based Templating syntax ▸ “Mustache” {{}} syntax for string interpolation and dynamic variables ▸ Directives ▸ prefixed with “v-“ ▸ accept arguments separated by “:” ▸ support modifiers prefixed with “.” ▸ Rendered via a virtual DOM, for efficient updates
  • 27. ROOM WITH A VUE TEMPLATES <template> <div class="form"> <div class="title cell"> <label>Title</label> <input ref="bookTitle" v-model="book.title" type="text"/> </div> <div class="pages cell"> <label>Pages</label> <input v-model="book.pages" type="text"/> </div> <div class="author cell"> <label>Author</label> <select v-model="book.author"> <option disabled selected value="">Choose Author</option> <option v-if="author !== null" v-bind:value="{ id: author.id }" v-for="author in authors">{{author.name}}</option> </select> </div> <div class="save cell"> <button @click="submitNewBook()" >Add Book</button> </div> </div> </template>
  • 28. ROOM WITH A VUE COMPONENTS ▸ Nested component hierarchy ▸ Each component renders either a template or returns createElement() calls (JSX is supported) ▸ Components typically defined in single files with <template>, <script>, and <style> sections
  • 29. ROOM WITH A VUE ECOSYSTEM ▸ State Management - Vuex ▸ Routing - Vue Router ▸ UI Libraries - VueStrap (3), BootstrapVue (4) & VueMaterial
  • 30. ROOM WITH A VUE ECOSYSTEM ▸ State Management - Vuex ▸ Routing - Vue Router ▸ UI Libraries ▸ VueStrap (Bootstrap 3) ▸ BootstrapVue (Bootstrap 4) ▸ VueMaterial (Material UI)
  • 31. ROOM WITH A VUE VUEX ▸ State-management library, a la Redux ▸ Provides conventions/constraints around application state ▸ Single store ▸ Data access via “getters” ▸ Data modifications via “mutations” ▸ Asynchronous work done in “actions”
  • 32. ROOM WITH A VUE VUEX ▸ The Store ▸ Top-level object: new Vuex.Store() ▸ Receives an object of properties, similar to Vue.Instance definition ▸ Single state tree (can be divided into modules) ▸ Store accessed by components via computed properties ▸ Store can only be modified by mutations
  • 33. ROOM WITH A VUE VUEX const store = new Vuex.Store({ state: { authors: [], books: [] }, mutations: { addBook (state, payload) { state.books.push(payload.book) }, addAuthor (state, payload) { console.log('adding author...') state.authors.push(payload.author) }, removeBook (state, payload) { state.books = state.books.filter(b => b.id !== payload.id) }, removeAuthor (state, payload) { state.books = state.authors.filter(b => b.id !== payload.id) }, setBooks (state, payload) { state.books = payload.books }, setAuthors (state, payload) { state.authors = payload.authors } } })
  • 34. ROOM WITH A VUE VUEX ▸ Getters ▸ “Computed properties” for store values ▸ Not needed for direct access to store properties ▸ Useful for filtering - `completedTodos`, `expiredSubs`, etc getters: { doneTodos: state => { return state.todos.filter(todo => todo.done) } }
  • 35. ROOM WITH A VUE VUEX ▸ Mutations ▸ Analogous to “events” - has a type & handler function ▸ Not called directly - instead “committed” to the store ▸ Can accept a “payload” argument (usually an object) ▸ Synchronous transactions only mutations: { addBook (state, payload) { state.books.push(payload.book) } }
  • 36. ROOM WITH A VUE VUEX ▸ Actions ▸ Store functions that commit mutations ▸ Are “dispatched” from the store ▸ Can perform asynchronous work (REST calls, etc) ▸ Can dispatch other actions ▸ Receive a “context” arg with access to store variables/ methods
  • 37. ROOM WITH A VUE VUEX ▸ Actions actions: { loadAuthors: function ({commit, state}) { fetch(`${state.serverURL}/author`) .then(r => r.json()) .then(json => commit('setAuthors', {authors: json})) .catch(e => console.warn(e)) } }
  • 38. ROOM WITH A VUE VUE-ROUTER ▸ First-class Router for Vue.js applications ▸ Similar conventions to React-Router < v4 ▸ Modes for hash (default) & browser history ▸ Redirects, URL params, wildcards, oh my!
  • 39. ROOM WITH A VUE COMPARE AND CONTRAST - ANGULAR ▸ A cleaner, simpler way to build apps ▸ Similar concepts/syntax: directives, templates, v-model ▸ More understandable, readable code ▸ Less code ▸ A rich, featureful API that doesn’t make you do everything with plain JavaScript ▸ Not a framework - you’ll still need to add packages
  • 40. ROOM WITH A VUE COMPARE AND CONTRAST - REACT ▸ Adding some magic back in to JavaScript ▸ Similar concepts/syntax: components, virtual DOM, lifecycle methods ▸ Supports JSX* ▸ Less code… sometimes ▸ Less opaque than Angular - but not “pure” JS
  • 41. ROOM WITH A VUE SUMMARY ▸ Vue.js is not “just” another JavaScript framework ▸ Aims for balance between rich, developer-friendly features and clean, understandable code ▸ Community is vibrant and engaged, and shows every sign of being in this for the long haul ▸ Vue.js is definitely worth learning, either as a first-timer’s JavaScript framework or for developers looking for a fresh view of SPAs
  • 42. ROOM WITH A VUE LINKS ▸ http://vuejs.org (links to Vuex/Vue-Router) ▸ https://github.com/vuejs/awesome-vue ▸ https://medium.com/unicorn-supplies/angular-vs-react-vs- vue-a-2017-comparison-c5c52d620176 ▸ https://medium.freecodecamp.org/between-the-wires-an- interview-with-vue-js-creator-evan-you-e383cbf57cc4
  • 43. ROOM WITH A VUE LINKS ▸ http://vuejs.org (links to Vuex/Vue-Router) ▸ https://github.com/vuejs/awesome-vue ▸ https://medium.com/unicorn-supplies/angular-vs-react-vs- vue-a-2017-comparison-c5c52d620176 ▸ https://medium.freecodecamp.org/between-the-wires-an- interview-with-vue-js-creator-evan-you-e383cbf57cc4
  • 44. ROOM WITH A VUE LINKS ▸ http://vuejs.org (links to Vuex/Vue-Router) ▸ https://github.com/vuejs/awesome-vue ▸ https://medium.com/unicorn-supplies/angular-vs-react-vs- vue-a-2017-comparison-c5c52d620176 ▸ https://medium.freecodecamp.org/between-the-wires-an- interview-with-vue-js-creator-evan-you-e383cbf57cc4
  • 45. THANK YOU Twitter: @ZacharyAKlein. Github: @ZacharyKlein. Email: zak@silver-chalice.com