SlideShare uma empresa Scribd logo
1 de 61
Vue: business-first
About me
Front-end developer in YouWe
Passion to comfortable UX
Developing front-end with Vue for POS platform
2/64
Agenda
• What is Vue?
• Why Vue became a popular?
• How to start with Vue?
• How component looks like?
• Events handling with Vue?
• Data-philosophy of Vue
• Vuex as official state manager
• Vue Router
• Weak sides of Vue
• Extra features of Vue
3/64
What is Vue?
• Component based framework
• Reactive (ES5)
• Virtual DOM (Snabbdom)
• Used in Alibaba/Taobao/Gitlab
4/64
Advantages of Vue
• Fast (~2x faster than React/Angular/Polymer)
• Small size (20kb min+gzip)
• Low feature delivery time
• Incrementaly adoptable
5/64
6/64http://www.timqian.com/star-history/#vuejs/vue&angular/angular&facebook/react
Why Vue became popular
7/64
Why Vue became popular
• Learning curve looks smooth in Vue
• Component approach good as mental model
• Corporate support (Alibaba/Taobao)
8/64
9
Start with CDN
<script
src="https://cdnjs.cloudflare.com/ajax
/libs/vue/2.4.4/vue.min.js"></script>
10/64
Start with npm
$ npm install –g vue-cli
$ vue init webpack projectName
# choose some to configuritaons for project
$ cd projectName
$ npm install
$ npm run dev
11
Components
12
Single File Component
Component.vue
<template>
…
</temlate>
<script>
…
</script>
<style>
…
</style>
13/64
Template
<template>
<div>
<p class=“greeting”
:class=“{‘text-bold’: isBold}”>
Hello {{ name }}</p>
<button @click=“toggleMessageBoldness”>
Click me</button>
<div>
</template>
14/64
Template
Script
Style
Script
<script>
export default {
data () {
return {
name: ‘Lviv’,
isBold: false
}
},
methods: {
toggleMessageBoldness() {
this.isBold = !this.isBold;
}
}
}
</script>
15/64
Template
Script
Style
Styles
<style scoped>
.greeting { color: red }
.text-bold { font-weight: bold }
</style>
16/64
Template
Script
Style
Preprocessors in Vue
17
Preprocessors in Vue
• Lang attribute on template/script/style
• Webpack Loader for preprocessor
18/64
Preprocessors in Vue
<template lang=“pug”>
div
p.greeting Hello, {{ name }}
</template>
<style lang=“scss”>
$primary-color: red;
.greeting {
color: $primary-color;
}
</style>
19/64
CSS preprocessor preset.
<style lang=“scss”>
@import(‘~assets/styles/preset.scss’);
.greeting {
color: $variable-from-preset;
}
</style>
20/64
Events handling
<template>
<form @submit.prevent.stop=“submitCallback”>
<input type=“text” @focus=“handleFocus”/>
</form>
</template>
22/64
Key events handling
<template>
<form @submit.prevent.stop=“submitCallback”>
<input type=“text” @keyup.13=“handleEnter”/>
</form>
</template>
23/64
Key events config
Vue.config.keyCodes = {
enter: 13,
escape: 27
“left-arrow”: 37
}
24/64
Init config
Vue.config.keyCodes = {
…
};
new Vue ({…});
25/64
In component
<template>
<input type=“text”
@key-up.enter=“handleEnter()”>
</template>
26/64
Vue Reactivity
27
Component state is reactive
export default {
data () {
return {
transactions: []
};
},
methods: {
loadTransactions () {
api.loadTransactions().then(transactions => {
this.transactions = transactions;
});
}
}
} 28/64
Watch changes
export default {
data () {
return {
transactionsCounter: 0
};
},
watch: {
transactionsCounter (newValue) {
// send to marketingTool metrics new value
}
}
} 29/64
Computed props
export default {
data () {
return {
firstName: ‘John’,
lastName: ‘Doe’,
alias: ‘Gun’
};
},
computed: {
formattedUserName() {
return this.firstName + this.firstName && this.alias ? ` (${this.alias)`:
this.alias + (this.firstName || this.alias) && this.lastName ?
`${lastName}`: this.lastName;
}
}
}
30/64
Vue data-flow philosophy
philosophy of Vue: props down, events up
Parent Child
32/64
Props
Events
Props down from parent to child
<template>
<div>
<p>{{ selectedValue }}</p>
<custom-select :value=“selectedValue”
:options=“parentsOptions”>
</div>
</template>
33/64
Events up from Child to Parent
<script>
export default {
props: {
value: {
type: Array
}
},
methods: {
pickValue (newSelectedValue) {
this.$emit(‘change’, newSelectedValue);
}
}
}
</script>
34/64
Handle changes
<template>
<div>
<p>{{ selectedValue }}</p>
<custom-select @change=“handleChangeSelect” :value=“selectedValue”
:options=“parentsOptions”>
</div>
</template>
<script>
export default {
methods: {
handleChangeSelect (newSelectedValue) {
this.selectedValue = newSelectedValue;
}
}
}
</script>
35/64
Two way data-binding with .sync
<template>
<div>
<p>{{ selectedValue }}</p>
<custom-select :value.sync=“selectedValue”
:options=“parentsOptions”>
</div>
</template>
36
Update value from Child
<script>
export default {
props: {
value: {
type: Array
}
},
methods: {
pickValue (valueThatUserPickedInSelect) {
this.$emit(‘update:value’, valueThatUserPickedInSelect);
}
}
}
</script>
37/64
Global data flow
• Event bus
• Vuex
38/64
Event Bus
export const Event Bus = new Vue ();
39/64
Event bus
EventBus.$emit(‘task:reload’) EventBus.$on(‘task:reload’,this.reload);
40/64
Vuex – state management
41/64
Vue Devtools
42/64
Vue Router
Route example
Import Tasks from ‘src/components/Tasks’
Import TaskById from ‘src/components/TaskById’
export default new Router({
… ,
routes: [{
path: '/tasks',
name: ‘Task',
component: Tasks,
children: [{
name: TaskByID',
path: ‘:id',
component: TaskById
}]
}]
}) 44/64
Router link
<router-link
:to=“{name: ‘TaskById’, params: {‘id’: 10}}”
tag=“a”>
</router-link>
45
Router View
<router-view>
// here will be rendered route-
component
</router-view>
46/64
Extra features of Vue
47
Vue supports JSX
<script>
export default {
data () {
name: ‘John Doe’
},
render(createElement) {
return createElement(<h1>Hello, { this.name }</h1>);
}
}
</script>
48/64
Dont forget plugin
{
test: /.vue$/,
exclude: [/node_modules/],
use: [{
loader: ‘babel-loader’,
options: { presets: [‘es2015’], plugins: [‘transfrom-vue-jsx’] }
}]
}
49/64
Typescript support
<template>
<h1 @click=“hello”> Hello {{ name }}</h1>
</template>
<script>
Import { Vue, Component } from ‘av-ts’
@Component
export default class App extends Vue {
name: string = ‘John Doe’
hello(): void { console.log(‘name’, this.name) }
}
</script>
50/64
IDE supports Vue
• Visual studio code has full Vue support
• JetBrains products has plugins for Vue
• Sublime/Atom has plugins for Vue
51/64
Weak parts of Vue
• Best practices
• Styles with preprocessors
• Plugins implemented by chinese comminuty (in very rare
situations)
52/64
What’s more with Vue
Server side rendering
54/64
Native Mobile Applications
55/64
Electron applications
59/64
Silver bullet?
57/64
Conclusion
• Vue is production ready
• Ecosystem became more and more stable
• Easy to learn
• Fast without optimizations
• Low feature delivery time
58/64
59
Contacts
Vitalii Ratyshyi
Email: v.ratyshnij@gmail.com
SkypeId: misreadable
Official Russian Vue telegram-chat: @vuejs_ru
60/64
Thanks for attention
Vitalii Ratyshyi
Email: v.ratyshnij@gmail.com
SkypeId: misreadable
Official Russian Vue telegram-chat: @vuejs_ru
61/64

Mais conteúdo relacionado

Mais procurados

Mais procurados (20)

Vue routing tutorial getting started with vue router
Vue routing tutorial getting started with vue routerVue routing tutorial getting started with vue router
Vue routing tutorial getting started with vue router
 
Vue Introduction
Vue IntroductionVue Introduction
Vue Introduction
 
Love at first Vue
Love at first VueLove at first Vue
Love at first Vue
 
Vue 淺談前端建置工具
Vue 淺談前端建置工具Vue 淺談前端建置工具
Vue 淺談前端建置工具
 
Enjoy the vue.js
Enjoy the vue.jsEnjoy the vue.js
Enjoy the vue.js
 
VueJS Introduction
VueJS IntroductionVueJS Introduction
VueJS Introduction
 
Room with a Vue - Introduction to Vue.js
Room with a Vue - Introduction to Vue.jsRoom with a Vue - Introduction to Vue.js
Room with a Vue - Introduction to Vue.js
 
Building a js widget
Building a js widgetBuilding a js widget
Building a js widget
 
Why Vue.js?
Why Vue.js?Why Vue.js?
Why Vue.js?
 
Vue.js
Vue.jsVue.js
Vue.js
 
Scalable Front-end Development with Vue.JS
Scalable Front-end Development with Vue.JSScalable Front-end Development with Vue.JS
Scalable Front-end Development with Vue.JS
 
Vue js 大型專案架構
Vue js 大型專案架構Vue js 大型專案架構
Vue js 大型專案架構
 
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
 
Javascript MVVM with Vue.JS
Javascript MVVM with Vue.JSJavascript MVVM with Vue.JS
Javascript MVVM with Vue.JS
 
An introduction to Vue.js
An introduction to Vue.jsAn introduction to Vue.js
An introduction to Vue.js
 
Building a Startup Stack with AngularJS
Building a Startup Stack with AngularJSBuilding a Startup Stack with AngularJS
Building a Startup Stack with AngularJS
 
第一次用 Vue.js 就愛上 [改]
第一次用 Vue.js 就愛上 [改]第一次用 Vue.js 就愛上 [改]
第一次用 Vue.js 就愛上 [改]
 
Web components
Web componentsWeb components
Web components
 
Vue presentation
Vue presentationVue presentation
Vue presentation
 
Vue js and Vue Material
Vue js and Vue MaterialVue js and Vue Material
Vue js and Vue Material
 

Semelhante a Vue business first

Using Backbone.js with Drupal 7 and 8
Using Backbone.js with Drupal 7 and 8Using Backbone.js with Drupal 7 and 8
Using Backbone.js with Drupal 7 and 8
Ovadiah Myrgorod
 

Semelhante a Vue business first (20)

Vue js and Dyploma
Vue js and DyplomaVue js and Dyploma
Vue js and Dyploma
 
以Vue開發電子商務網站
架構與眉角
以Vue開發電子商務網站
架構與眉角以Vue開發電子商務網站
架構與眉角
以Vue開發電子商務網站
架構與眉角
 
From framework coupled code to #microservices through #DDD /by @codelytv
From framework coupled code to #microservices through #DDD /by @codelytvFrom framework coupled code to #microservices through #DDD /by @codelytv
From framework coupled code to #microservices through #DDD /by @codelytv
 
Backbone js-slides
Backbone js-slidesBackbone js-slides
Backbone js-slides
 
Aurelia Meetup Paris
Aurelia Meetup ParisAurelia Meetup Paris
Aurelia Meetup Paris
 
Building and deploying React applications
Building and deploying React applicationsBuilding and deploying React applications
Building and deploying React applications
 
WordCamp Montreal 2016 WP-API + React with server rendering
WordCamp Montreal 2016  WP-API + React with server renderingWordCamp Montreal 2016  WP-API + React with server rendering
WordCamp Montreal 2016 WP-API + React with server rendering
 
Building Universal Web Apps with React ForwardJS 2017
Building Universal Web Apps with React ForwardJS 2017Building Universal Web Apps with React ForwardJS 2017
Building Universal Web Apps with React ForwardJS 2017
 
Using Backbone.js with Drupal 7 and 8
Using Backbone.js with Drupal 7 and 8Using Backbone.js with Drupal 7 and 8
Using Backbone.js with Drupal 7 and 8
 
Vuejs
VuejsVuejs
Vuejs
 
Django + Vue, JavaScript de 3ª generación para modernizar Django
Django + Vue, JavaScript de 3ª generación para modernizar DjangoDjango + Vue, JavaScript de 3ª generación para modernizar Django
Django + Vue, JavaScript de 3ª generación para modernizar Django
 
SproutCore and the Future of Web Apps
SproutCore and the Future of Web AppsSproutCore and the Future of Web Apps
SproutCore and the Future of Web Apps
 
Universal JavaScript Web Applications with React - Luciano Mammino - Codemoti...
Universal JavaScript Web Applications with React - Luciano Mammino - Codemoti...Universal JavaScript Web Applications with React - Luciano Mammino - Codemoti...
Universal JavaScript Web Applications with React - Luciano Mammino - Codemoti...
 
Universal JS Web Applications with React - Luciano Mammino - Codemotion Rome ...
Universal JS Web Applications with React - Luciano Mammino - Codemotion Rome ...Universal JS Web Applications with React - Luciano Mammino - Codemotion Rome ...
Universal JS Web Applications with React - Luciano Mammino - Codemotion Rome ...
 
How to Webpack your Django!
How to Webpack your Django!How to Webpack your Django!
How to Webpack your Django!
 
Building an Angular 2 App
Building an Angular 2 AppBuilding an Angular 2 App
Building an Angular 2 App
 
How to implement multiple layouts using React router V4.pptx
How to implement multiple layouts using React router V4.pptxHow to implement multiple layouts using React router V4.pptx
How to implement multiple layouts using React router V4.pptx
 
Lecture: Webpack 4
Lecture: Webpack 4Lecture: Webpack 4
Lecture: Webpack 4
 
Front End Development for Back End Java Developers - Jfokus 2020
Front End Development for Back End Java Developers - Jfokus 2020Front End Development for Back End Java Developers - Jfokus 2020
Front End Development for Back End Java Developers - Jfokus 2020
 
Angular 2 Architecture (Bucharest 26/10/2016)
Angular 2 Architecture (Bucharest 26/10/2016)Angular 2 Architecture (Bucharest 26/10/2016)
Angular 2 Architecture (Bucharest 26/10/2016)
 

Último

CALL ON ➥8923113531 🔝Call Girls Kakori Lucknow best sexual service Online ☂️
CALL ON ➥8923113531 🔝Call Girls Kakori Lucknow best sexual service Online  ☂️CALL ON ➥8923113531 🔝Call Girls Kakori Lucknow best sexual service Online  ☂️
CALL ON ➥8923113531 🔝Call Girls Kakori Lucknow best sexual service Online ☂️
anilsa9823
 
+971565801893>>SAFE AND ORIGINAL ABORTION PILLS FOR SALE IN DUBAI AND ABUDHAB...
+971565801893>>SAFE AND ORIGINAL ABORTION PILLS FOR SALE IN DUBAI AND ABUDHAB...+971565801893>>SAFE AND ORIGINAL ABORTION PILLS FOR SALE IN DUBAI AND ABUDHAB...
+971565801893>>SAFE AND ORIGINAL ABORTION PILLS FOR SALE IN DUBAI AND ABUDHAB...
Health
 
TECUNIQUE: Success Stories: IT Service provider
TECUNIQUE: Success Stories: IT Service providerTECUNIQUE: Success Stories: IT Service provider
TECUNIQUE: Success Stories: IT Service provider
mohitmore19
 

Último (20)

How To Troubleshoot Collaboration Apps for the Modern Connected Worker
How To Troubleshoot Collaboration Apps for the Modern Connected WorkerHow To Troubleshoot Collaboration Apps for the Modern Connected Worker
How To Troubleshoot Collaboration Apps for the Modern Connected Worker
 
HR Software Buyers Guide in 2024 - HRSoftware.com
HR Software Buyers Guide in 2024 - HRSoftware.comHR Software Buyers Guide in 2024 - HRSoftware.com
HR Software Buyers Guide in 2024 - HRSoftware.com
 
Tech Tuesday-Harness the Power of Effective Resource Planning with OnePlan’s ...
Tech Tuesday-Harness the Power of Effective Resource Planning with OnePlan’s ...Tech Tuesday-Harness the Power of Effective Resource Planning with OnePlan’s ...
Tech Tuesday-Harness the Power of Effective Resource Planning with OnePlan’s ...
 
Learn the Fundamentals of XCUITest Framework_ A Beginner's Guide.pdf
Learn the Fundamentals of XCUITest Framework_ A Beginner's Guide.pdfLearn the Fundamentals of XCUITest Framework_ A Beginner's Guide.pdf
Learn the Fundamentals of XCUITest Framework_ A Beginner's Guide.pdf
 
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-...
 
W01_panagenda_Navigating-the-Future-with-The-Hitchhikers-Guide-to-Notes-and-D...
W01_panagenda_Navigating-the-Future-with-The-Hitchhikers-Guide-to-Notes-and-D...W01_panagenda_Navigating-the-Future-with-The-Hitchhikers-Guide-to-Notes-and-D...
W01_panagenda_Navigating-the-Future-with-The-Hitchhikers-Guide-to-Notes-and-D...
 
Reassessing the Bedrock of Clinical Function Models: An Examination of Large ...
Reassessing the Bedrock of Clinical Function Models: An Examination of Large ...Reassessing the Bedrock of Clinical Function Models: An Examination of Large ...
Reassessing the Bedrock of Clinical Function Models: An Examination of Large ...
 
Software Quality Assurance Interview Questions
Software Quality Assurance Interview QuestionsSoftware Quality Assurance Interview Questions
Software Quality Assurance Interview Questions
 
CALL ON ➥8923113531 🔝Call Girls Kakori Lucknow best sexual service Online ☂️
CALL ON ➥8923113531 🔝Call Girls Kakori Lucknow best sexual service Online  ☂️CALL ON ➥8923113531 🔝Call Girls Kakori Lucknow best sexual service Online  ☂️
CALL ON ➥8923113531 🔝Call Girls Kakori Lucknow best sexual service Online ☂️
 
The Real-World Challenges of Medical Device Cybersecurity- Mitigating Vulnera...
The Real-World Challenges of Medical Device Cybersecurity- Mitigating Vulnera...The Real-World Challenges of Medical Device Cybersecurity- Mitigating Vulnera...
The Real-World Challenges of Medical Device Cybersecurity- Mitigating Vulnera...
 
Hand gesture recognition PROJECT PPT.pptx
Hand gesture recognition PROJECT PPT.pptxHand gesture recognition PROJECT PPT.pptx
Hand gesture recognition PROJECT PPT.pptx
 
Microsoft AI Transformation Partner Playbook.pdf
Microsoft AI Transformation Partner Playbook.pdfMicrosoft AI Transformation Partner Playbook.pdf
Microsoft AI Transformation Partner Playbook.pdf
 
How To Use Server-Side Rendering with Nuxt.js
How To Use Server-Side Rendering with Nuxt.jsHow To Use Server-Side Rendering with Nuxt.js
How To Use Server-Side Rendering with Nuxt.js
 
Try MyIntelliAccount Cloud Accounting Software As A Service Solution Risk Fre...
Try MyIntelliAccount Cloud Accounting Software As A Service Solution Risk Fre...Try MyIntelliAccount Cloud Accounting Software As A Service Solution Risk Fre...
Try MyIntelliAccount Cloud Accounting Software As A Service Solution Risk Fre...
 
Steps To Getting Up And Running Quickly With MyTimeClock Employee Scheduling ...
Steps To Getting Up And Running Quickly With MyTimeClock Employee Scheduling ...Steps To Getting Up And Running Quickly With MyTimeClock Employee Scheduling ...
Steps To Getting Up And Running Quickly With MyTimeClock Employee Scheduling ...
 
+971565801893>>SAFE AND ORIGINAL ABORTION PILLS FOR SALE IN DUBAI AND ABUDHAB...
+971565801893>>SAFE AND ORIGINAL ABORTION PILLS FOR SALE IN DUBAI AND ABUDHAB...+971565801893>>SAFE AND ORIGINAL ABORTION PILLS FOR SALE IN DUBAI AND ABUDHAB...
+971565801893>>SAFE AND ORIGINAL ABORTION PILLS FOR SALE IN DUBAI AND ABUDHAB...
 
TECUNIQUE: Success Stories: IT Service provider
TECUNIQUE: Success Stories: IT Service providerTECUNIQUE: Success Stories: IT Service provider
TECUNIQUE: Success Stories: IT Service provider
 
Unveiling the Tech Salsa of LAMs with Janus in Real-Time Applications
Unveiling the Tech Salsa of LAMs with Janus in Real-Time ApplicationsUnveiling the Tech Salsa of LAMs with Janus in Real-Time Applications
Unveiling the Tech Salsa of LAMs with Janus in Real-Time Applications
 
5 Signs You Need a Fashion PLM Software.pdf
5 Signs You Need a Fashion PLM Software.pdf5 Signs You Need a Fashion PLM Software.pdf
5 Signs You Need a Fashion PLM Software.pdf
 
Optimizing AI for immediate response in Smart CCTV
Optimizing AI for immediate response in Smart CCTVOptimizing AI for immediate response in Smart CCTV
Optimizing AI for immediate response in Smart CCTV
 

Vue business first