SlideShare a Scribd company logo
Vue.js - part 1
Vue.js - inswave systems, 2018 1
Concept overview
Vue (pronounced /vjuː/, like view) is a progressive framework
for building user interfaces. Unlike other monolithic
frameworks, Vue is designed from the ground up to be
incrementally adoptable. The core library is focused on the
view layer only, and is easy to pick up and integrate with
other libraries or existing projects.
Vue.js - inswave systems, 2018 2
MVVM
Backend Client & MVC .
DB , Model View
.
Vue.js - inswave systems, 2018 3
MVVM in Vue
Vue.js - inswave systems, 2018 4
View Instance - ViewModel
Every Vue application starts by creating a new Vue instance with the Vue
function:
new Vue({
el: '#app',
data: {
message: 'Hello Vue.js!'
}
});
Although not strictly associated with the MVVM pattern, Vue’s design was
partly inspired by it.
Vue.js - inswave systems, 2018 5
View Instance(Option)
el DOM
data
template HTML, CSS
method
created View Instance
Vue.js - inswave systems, 2018 6
View
The actual DOM that is managed by Vue instances.
vm.$el // The View
Vue.js - inswave systems, 2018 7
Model
A slightly modified plain JavaScript
object.
vm.$data // The Model
Vue.js - inswave systems, 2018 8
Directive
Prefixed HTML attributes that tell Vue.js to do something about
a DOM element.
<div v-text="message"></div>
Vue.js - inswave systems, 2018 9
Mustache Bindings
You can also use mustache-style bindings, both in text and in
attributes. They are translated into v-text and v-attr directives
under the hood. For example:
<div id="person-{{id}}">Hello {{name}}!</div>
Vue.js - inswave systems, 2018 10
Filters
Filters are functions used to process the raw values before
updating the View. They are denoted by a “pipe” inside
directives or bindings:
<div>{{message | capitalize}}</div>
Vue.js - inswave systems, 2018 11
Quick example
<div id="demo">
<h1>{{title | uppercase}}</h1>
<ul>
<li v-repeat="todos" v-on="click: done = !done"
class="{{done ? 'done' : ''}}">
{{content}}
</li>
</ul>
</div>
( ...)
Vue.js - inswave systems, 2018 12
Quick example
var demo = new Vue({
el: '#demo',
data: {
title: 'todos',
todos: [
{done: true, content: 'JavaScript'},
{done: false, content: 'Vue.js'}
]
}
})
Vue.js - inswave systems, 2018 13
View Instance View Instance DOM
.
Vue.js - inswave systems, 2018 14
Lifecycle
1. new Vue()
2. => beforeCreate
3. => created
4. el, template => beforeMount
5. $el el => mounted
6.
7. => beforeUpdate
8. => updated
9.
10. => beforeDestroy
11. , => destroyed
12.
Vue.js - inswave systems, 2018 15
Vue.js - inswave systems, 2018 16
Vue.component()
<script>Vue.component('my-global-component', {})</script>
<div id="app">
<my-global-component></my-global-component>
</div>
Vue.js - inswave systems, 2018 17
components
<script>
new Vue({
el: '#app',
components: {
'my-local-component' : { template: '<div>local component</div>'}
}
});
</script>
<div id="app">
<my-local-component></my-local-component>
</div>
Vue.js - inswave systems, 2018 18
• (props )
•
•
Vue.js - inswave systems, 2018 19
• props
• HTML v-bind:
<script>
Vue.component('child-component', {
props: ['propsdata'],
});
</script>
<child-component v-bind:props =" data ">
</child-component>
Vue.js - inswave systems, 2018 20
<script>
Vue.component('child-component', {
props: ['propsdata'],
template: '<p>{{ propsdata }}</p>'
});
new Vue({
el: '#app',
data: {message:'Hello Vue! passed from Parent Component'}
});
</script>
<div id="app>
<child-component v-bind:propsdata="message"></child-component>
</div>
Vue.js - inswave systems, 2018 21
<script>
//
this.$emit(' ')
</script>
<child-component v-on: =" ">
</child-component>
Vue.js - inswave systems, 2018 22
<div id="app">
<my-local-component v-on:show-log="printText"></my-local-component>
</div>
<script>
new Vue({
el: '#app',
components: {
'my-local-component' : {
template: '<button v-on:click="showLog">showLog</button>',
methods: {showLog: function() {this.$emit('show-log');}}
}
},
methods: {printText: function() {console.log('recevied an event');}}
});
</script>
Vue.js - inswave systems, 2018 23
.
.
//
var eventBus = new Vue();
//
methods: {
method : function() { eventBus.$emit(' ', ); }
}
//
methods: {
created: function() { eventBus.$on(" ", function( ) { ... }); }
}
Vue.js - inswave systems, 2018 24
<div id="app">
<my-local-component></my-local-component>
</div>
<script>
var eventBus = new Vue();
new Vue({
el: '#app',
components: {
'my-local-component' : {
template: '<button v-on:click="showLog">showLog</button>',
methods: {
showLog: function() {eventBus.$emit('sendEvent', 'data');}
}
}
},
created: function() {
eventBus.$on('sendEvent', function(retVal) {
console.log('recevied an event : ' + retVal);
});
}
});
</script>
Vue.js - inswave systems, 2018 25
v-bind Shorthand
<!-- full syntax -->
<a v-bind:href="url"> ... </a>
<!-- shorthand -->
<a :href="url"> ... </a>
Vue.js - inswave systems, 2018 26
v-on Shorthand
<!-- full syntax -->
<a v-on:click="doSomething"> ... </a>
<!-- shorthand -->
<a @click="doSomething"> ... </a>
Vue.js - inswave systems, 2018 27
• : SPA .
• :
<router-link to="URL " . <a>
to URL
<router-view> . URL
Vue.js - inswave systems, 2018 28
<div id="app">
<h1> </h1>
<p>
<router-link to="/main"> </router-link>
</p>
<router-view></router-view>
</div>
<script>
var Main = { template : '<div>main</div>' };
var routes = [
{ path: '/main', component: Main }
];
var router = new VueRouter({routes});
var app = new Vue({router}).$mount('#app');
</script>
Vue.js - inswave systems, 2018 29
<router-view> . route children
.
<div id="app"><router-view></router-view></div>
<script>
var User = {template: '<div>User<router-view></router-view></div>';};
var UserProfile = { template: '<p>User Profile Component</p>'};
var routes = [{
path: '/user', component: User,
children: [{path: 'profile',component: UserProfile}]
}];
var router = new VueRouter({routes});
var app = new Vue({router}).$mount('#app');
</script>
Vue.js - inswave systems, 2018 30
name <router-view> . default .
<div id="app">
<router-view name="header"></router-view>
<router-view></router-view>
<router-view name="footer"></router-view>
</div>
<script>
var Header = {template: '<div>Header Component</div>'};
var Footer = {template: '<div>Footer Component</div>'};
var Body = {template: '<div>Body Component</div>'};
var routes = [{path: '/',
components: {default:Body, header:Header, footer:Footer}}];
var router = new VueRouter({routes});
Vue.js - inswave systems, 2018 31
vs
Vue.js - inswave systems, 2018 32
Vue.js - inswave systems, 2018 33

More Related Content

PDF
Modern frontend development with VueJs
PDF
Room with a Vue - Introduction to Vue.js
PDF
Love at first Vue
PDF
Vue js and Vue Material
PDF
The Point of Vue - Intro to Vue.js
PPTX
Vue business first
PPTX
Web components
PDF
Modern frontend development with VueJs
Room with a Vue - Introduction to Vue.js
Love at first Vue
Vue js and Vue Material
The Point of Vue - Intro to Vue.js
Vue business first
Web components

What's hot (20)

PPTX
An introduction to Vue.js
PDF
VueJS Introduction
PDF
An introduction to Vue.js
PDF
Why Vue.js?
PDF
Introduction to VueJS & Vuex
PPT
Vue.js Getting Started
PPTX
Vue presentation
ODP
An Introduction to Vuejs
PDF
Building a js widget
PDF
Vue, vue router, vuex
PDF
Vaadin 7 CN
PDF
Vue routing tutorial getting started with vue router
PPTX
How to Build SPA with Vue Router 2.0
PDF
Vue js 大型專案架構
PDF
How to Build ToDo App with Vue 3 + TypeScript
PDF
Vaadin Components @ Angular U
PPTX
Vue 2.0 + Vuex Router & Vuex at Vue.js
PDF
Building and deploying React applications
PDF
Universal JS Web Applications with React - Luciano Mammino - Codemotion Rome ...
An introduction to Vue.js
VueJS Introduction
An introduction to Vue.js
Why Vue.js?
Introduction to VueJS & Vuex
Vue.js Getting Started
Vue presentation
An Introduction to Vuejs
Building a js widget
Vue, vue router, vuex
Vaadin 7 CN
Vue routing tutorial getting started with vue router
How to Build SPA with Vue Router 2.0
Vue js 大型專案架構
How to Build ToDo App with Vue 3 + TypeScript
Vaadin Components @ Angular U
Vue 2.0 + Vuex Router & Vuex at Vue.js
Building and deploying React applications
Universal JS Web Applications with React - Luciano Mammino - Codemotion Rome ...
Ad

Similar to Vue.js part1 (20)

PDF
Vue.js for beginners
PDF
Vue.js - An Introduction
PDF
Vue.js 101
PDF
Vue.js
PDF
Meet VueJs
PPTX
Basics of Vue.js 2019
PDF
Vue js 2.x
PPTX
An introduction to Vue.js
PPTX
Level up apps and websites with vue.js
PPTX
Level up apps and websites with vue.js
PDF
Introduction to Vue.js
PDF
ITB2019 ColdBox APIs + VueJS - powering Mobile, Desktop and Web Apps with 1 V...
PDF
introduction to Vue.js 3
PDF
Learning Vue Directives.pdf
PDF
Vue JS Intro
PPTX
ColdBox APIs + VueJS - powering Mobile, Desktop and Web Apps with 1 VueJS cod...
PPTX
Introduction to web application development with Vue (for absolute beginners)...
ODP
Basics of VueJS
PDF
Quasar Framework Introduction for C++ develpoers
Vue.js for beginners
Vue.js - An Introduction
Vue.js 101
Vue.js
Meet VueJs
Basics of Vue.js 2019
Vue js 2.x
An introduction to Vue.js
Level up apps and websites with vue.js
Level up apps and websites with vue.js
Introduction to Vue.js
ITB2019 ColdBox APIs + VueJS - powering Mobile, Desktop and Web Apps with 1 V...
introduction to Vue.js 3
Learning Vue Directives.pdf
Vue JS Intro
ColdBox APIs + VueJS - powering Mobile, Desktop and Web Apps with 1 VueJS cod...
Introduction to web application development with Vue (for absolute beginners)...
Basics of VueJS
Quasar Framework Introduction for C++ develpoers
Ad

More from 욱래 김 (8)

PDF
0003 es5 핵심 정리
PDF
엔터프라이즈 웹 동향 및 적용사례
PDF
차세대 웹(Html5) 플랫폼의 동향과 기업 업무 적용 방안
PDF
W3C TPAC 2014
PDF
HTML5 플랫폼 동향과 기업업무 적용 방안
PDF
강의자료 차세대 웹(Html5) 플랫폼의 동향과 구축 방안
PDF
HTML5 & Hybrid App Trends
PDF
스마트시대를 준비하는 웹표준 RIA
0003 es5 핵심 정리
엔터프라이즈 웹 동향 및 적용사례
차세대 웹(Html5) 플랫폼의 동향과 기업 업무 적용 방안
W3C TPAC 2014
HTML5 플랫폼 동향과 기업업무 적용 방안
강의자료 차세대 웹(Html5) 플랫폼의 동향과 구축 방안
HTML5 & Hybrid App Trends
스마트시대를 준비하는 웹표준 RIA

Recently uploaded (20)

PDF
Which alternative to Crystal Reports is best for small or large businesses.pdf
PPTX
Agentic AI Use Case- Contract Lifecycle Management (CLM).pptx
PDF
Softaken Excel to vCard Converter Software.pdf
PDF
EN-Survey-Report-SAP-LeanIX-EA-Insights-2025.pdf
PDF
wealthsignaloriginal-com-DS-text-... (1).pdf
PDF
Claude Code: Everyone is a 10x Developer - A Comprehensive AI-Powered CLI Tool
PDF
Why TechBuilder is the Future of Pickup and Delivery App Development (1).pdf
PPTX
Reimagine Home Health with the Power of Agentic AI​
PPTX
Log360_SIEM_Solutions Overview PPT_Feb 2020.pptx
PDF
Adobe Illustrator 28.6 Crack My Vision of Vector Design
PDF
Product Update: Alluxio AI 3.7 Now with Sub-Millisecond Latency
PDF
Design an Analysis of Algorithms II-SECS-1021-03
PDF
System and Network Administraation Chapter 3
PDF
Design an Analysis of Algorithms I-SECS-1021-03
PDF
medical staffing services at VALiNTRY
PPTX
Odoo POS Development Services by CandidRoot Solutions
PDF
Designing Intelligence for the Shop Floor.pdf
PDF
SAP S4 Hana Brochure 3 (PTS SYSTEMS AND SOLUTIONS)
PPTX
Introduction to Artificial Intelligence
PPTX
assetexplorer- product-overview - presentation
Which alternative to Crystal Reports is best for small or large businesses.pdf
Agentic AI Use Case- Contract Lifecycle Management (CLM).pptx
Softaken Excel to vCard Converter Software.pdf
EN-Survey-Report-SAP-LeanIX-EA-Insights-2025.pdf
wealthsignaloriginal-com-DS-text-... (1).pdf
Claude Code: Everyone is a 10x Developer - A Comprehensive AI-Powered CLI Tool
Why TechBuilder is the Future of Pickup and Delivery App Development (1).pdf
Reimagine Home Health with the Power of Agentic AI​
Log360_SIEM_Solutions Overview PPT_Feb 2020.pptx
Adobe Illustrator 28.6 Crack My Vision of Vector Design
Product Update: Alluxio AI 3.7 Now with Sub-Millisecond Latency
Design an Analysis of Algorithms II-SECS-1021-03
System and Network Administraation Chapter 3
Design an Analysis of Algorithms I-SECS-1021-03
medical staffing services at VALiNTRY
Odoo POS Development Services by CandidRoot Solutions
Designing Intelligence for the Shop Floor.pdf
SAP S4 Hana Brochure 3 (PTS SYSTEMS AND SOLUTIONS)
Introduction to Artificial Intelligence
assetexplorer- product-overview - presentation

Vue.js part1

  • 1. Vue.js - part 1 Vue.js - inswave systems, 2018 1
  • 2. Concept overview Vue (pronounced /vjuː/, like view) is a progressive framework for building user interfaces. Unlike other monolithic frameworks, Vue is designed from the ground up to be incrementally adoptable. The core library is focused on the view layer only, and is easy to pick up and integrate with other libraries or existing projects. Vue.js - inswave systems, 2018 2
  • 3. MVVM Backend Client & MVC . DB , Model View . Vue.js - inswave systems, 2018 3
  • 4. MVVM in Vue Vue.js - inswave systems, 2018 4
  • 5. View Instance - ViewModel Every Vue application starts by creating a new Vue instance with the Vue function: new Vue({ el: '#app', data: { message: 'Hello Vue.js!' } }); Although not strictly associated with the MVVM pattern, Vue’s design was partly inspired by it. Vue.js - inswave systems, 2018 5
  • 6. View Instance(Option) el DOM data template HTML, CSS method created View Instance Vue.js - inswave systems, 2018 6
  • 7. View The actual DOM that is managed by Vue instances. vm.$el // The View Vue.js - inswave systems, 2018 7
  • 8. Model A slightly modified plain JavaScript object. vm.$data // The Model Vue.js - inswave systems, 2018 8
  • 9. Directive Prefixed HTML attributes that tell Vue.js to do something about a DOM element. <div v-text="message"></div> Vue.js - inswave systems, 2018 9
  • 10. Mustache Bindings You can also use mustache-style bindings, both in text and in attributes. They are translated into v-text and v-attr directives under the hood. For example: <div id="person-{{id}}">Hello {{name}}!</div> Vue.js - inswave systems, 2018 10
  • 11. Filters Filters are functions used to process the raw values before updating the View. They are denoted by a “pipe” inside directives or bindings: <div>{{message | capitalize}}</div> Vue.js - inswave systems, 2018 11
  • 12. Quick example <div id="demo"> <h1>{{title | uppercase}}</h1> <ul> <li v-repeat="todos" v-on="click: done = !done" class="{{done ? 'done' : ''}}"> {{content}} </li> </ul> </div> ( ...) Vue.js - inswave systems, 2018 12
  • 13. Quick example var demo = new Vue({ el: '#demo', data: { title: 'todos', todos: [ {done: true, content: 'JavaScript'}, {done: false, content: 'Vue.js'} ] } }) Vue.js - inswave systems, 2018 13
  • 14. View Instance View Instance DOM . Vue.js - inswave systems, 2018 14
  • 15. Lifecycle 1. new Vue() 2. => beforeCreate 3. => created 4. el, template => beforeMount 5. $el el => mounted 6. 7. => beforeUpdate 8. => updated 9. 10. => beforeDestroy 11. , => destroyed 12. Vue.js - inswave systems, 2018 15
  • 16. Vue.js - inswave systems, 2018 16
  • 18. components <script> new Vue({ el: '#app', components: { 'my-local-component' : { template: '<div>local component</div>'} } }); </script> <div id="app"> <my-local-component></my-local-component> </div> Vue.js - inswave systems, 2018 18
  • 19. • (props ) • • Vue.js - inswave systems, 2018 19
  • 20. • props • HTML v-bind: <script> Vue.component('child-component', { props: ['propsdata'], }); </script> <child-component v-bind:props =" data "> </child-component> Vue.js - inswave systems, 2018 20
  • 21. <script> Vue.component('child-component', { props: ['propsdata'], template: '<p>{{ propsdata }}</p>' }); new Vue({ el: '#app', data: {message:'Hello Vue! passed from Parent Component'} }); </script> <div id="app> <child-component v-bind:propsdata="message"></child-component> </div> Vue.js - inswave systems, 2018 21
  • 22. <script> // this.$emit(' ') </script> <child-component v-on: =" "> </child-component> Vue.js - inswave systems, 2018 22
  • 23. <div id="app"> <my-local-component v-on:show-log="printText"></my-local-component> </div> <script> new Vue({ el: '#app', components: { 'my-local-component' : { template: '<button v-on:click="showLog">showLog</button>', methods: {showLog: function() {this.$emit('show-log');}} } }, methods: {printText: function() {console.log('recevied an event');}} }); </script> Vue.js - inswave systems, 2018 23
  • 24. . . // var eventBus = new Vue(); // methods: { method : function() { eventBus.$emit(' ', ); } } // methods: { created: function() { eventBus.$on(" ", function( ) { ... }); } } Vue.js - inswave systems, 2018 24
  • 25. <div id="app"> <my-local-component></my-local-component> </div> <script> var eventBus = new Vue(); new Vue({ el: '#app', components: { 'my-local-component' : { template: '<button v-on:click="showLog">showLog</button>', methods: { showLog: function() {eventBus.$emit('sendEvent', 'data');} } } }, created: function() { eventBus.$on('sendEvent', function(retVal) { console.log('recevied an event : ' + retVal); }); } }); </script> Vue.js - inswave systems, 2018 25
  • 26. v-bind Shorthand <!-- full syntax --> <a v-bind:href="url"> ... </a> <!-- shorthand --> <a :href="url"> ... </a> Vue.js - inswave systems, 2018 26
  • 27. v-on Shorthand <!-- full syntax --> <a v-on:click="doSomething"> ... </a> <!-- shorthand --> <a @click="doSomething"> ... </a> Vue.js - inswave systems, 2018 27
  • 28. • : SPA . • : <router-link to="URL " . <a> to URL <router-view> . URL Vue.js - inswave systems, 2018 28
  • 29. <div id="app"> <h1> </h1> <p> <router-link to="/main"> </router-link> </p> <router-view></router-view> </div> <script> var Main = { template : '<div>main</div>' }; var routes = [ { path: '/main', component: Main } ]; var router = new VueRouter({routes}); var app = new Vue({router}).$mount('#app'); </script> Vue.js - inswave systems, 2018 29
  • 30. <router-view> . route children . <div id="app"><router-view></router-view></div> <script> var User = {template: '<div>User<router-view></router-view></div>';}; var UserProfile = { template: '<p>User Profile Component</p>'}; var routes = [{ path: '/user', component: User, children: [{path: 'profile',component: UserProfile}] }]; var router = new VueRouter({routes}); var app = new Vue({router}).$mount('#app'); </script> Vue.js - inswave systems, 2018 30
  • 31. name <router-view> . default . <div id="app"> <router-view name="header"></router-view> <router-view></router-view> <router-view name="footer"></router-view> </div> <script> var Header = {template: '<div>Header Component</div>'}; var Footer = {template: '<div>Footer Component</div>'}; var Body = {template: '<div>Body Component</div>'}; var routes = [{path: '/', components: {default:Body, header:Header, footer:Footer}}]; var router = new VueRouter({routes}); Vue.js - inswave systems, 2018 31
  • 32. vs Vue.js - inswave systems, 2018 32
  • 33. Vue.js - inswave systems, 2018 33