Resumer VueJS 3
Resumer VueJS 3
Prepared By:
Harikrusha V. Adiecha
Senior Software Engineer @ Improwised Technology
What is VueJS
● Progressive frontend framework
● Best for Single Page Application (SPA)
● Founder - Evan You (Independent Software Developer And Creator of Vuejs)
● Releases
○ Initial (v0.10) in 2014
○ v1.0 in 2015
○ v2.0 in 2016
○ v2.6 current
Why Vue?
● Easy to learn
● Light weight (94kb) - where angular - 178kb and react - 119 + 13 kb
● Reactivity (two way data binding)
● Reusable components
● Virtual DOM
Hello Word
Hello Word - Installation (inject CDN)
<!-- development version, includes helpful console warnings -->
<script src="https://cdn.jsdelivr.net/npm/vue/dist/vue.js"></script>
Or
That’s it.
Hello Word - Code
HTML Output:
JavaScript
● Vue Instance
● Options
○ el (string) - to plugin code to HTML
○ data (json of data)- add all properties found in data to vue’s reactivity system.
○ methods (json of function)- methods object which can be called from html using event bindings.
○ computed (json of function) - derived data property will be specified here
○ mounted (function) - this will be a lifecycle hook, called when mounted.
○ created (function) - this will be a lifecycle hook, called when created.
○ Many more...
Hello Word - Explaination
<h1> {{ greeting }} </h1>
{{ ‘Hello ‘ + name }}
{{ firstName + ‘ ‘ + lastName }}
{{ message.split(‘’).reverse().join(‘’) }}
{{ num + 1 }}
{{ isActive ? ‘Active’ : ‘Inactive’ }}
Rendering with Condition & Loop
Basic Rendering
- v-show
- v-if
- v-else-if
- v-else
( `v-show` ) Will keep element in the dom, and just change display style (none or block)
( `v-if` ) will remove entire element from the dom
Conditional Rendering (v-if, v-else)
HTML Output:
JavaScript
JavaScript
Here href is the argument, which tells the v-bind directive to bind the element’s href attribute to the value of
the expression url.
Here it will listen click event triggered from dom element button and call action method specified in the
methods option.
In simple words this code will call action method when some one click on the button.
● .stop ● .enter
● .prevent ● .tab
● .self ● .delete
● .up
● .f1
Reactive Form Inputs
Directive ( `v-model` )
This directive is used to create two-way data bindings on form inputs.
● Text
● Multiline Text
● Select
● Checkbox
● Radio
Text & Multiline text
<input v-model="message" placeholder="edit me">
<p>Message is: {{ message }}</p>
This will apply changes right a way to following p tag as made changes in text box
Checkbox
Single checkbox, boolean value.
This will show true or false right next to checkbox, as we select or deselect them.
Radio button
<input type="radio" id="one" value="One" v-model="picked">
<label for="one">One</label>
<br>
<input type="radio" id="two" value="Two" v-model="picked">
<label for="two">Two</label>
<br>
<span>Picked: {{ picked }}</span>
Select
<select v-model="selected"> new Vue({
<option disabled value=""> el: '#app',
Please select one data: {
</option> selected: ‘’
<option>A</option> }
<option>B</option>
})
<option>C</option>
</select>
Vue.component(‘comp-name’, {
template: ‘#compo’, // template id or direct html
data: function() { return {}; } // return properties json object
props: [‘a’] // input from parent
// Other options
});
Vue Component
Basically, components are reusable vue instance with name.
Thank you.