What is Vue.js?
Vu.js is a open source JavaScript framework which is used for developing dynamic views or interfaces of web applications.It is usually used for creating the views of Single Page Applications. Though Vuejs is used for building the UIs but it can be easily integrated with other JavaScript libraries for creating Single Page Applications.
It uses virtual DOM just like React which is a slimmed down version of DOM.
How do you include Vue JS library in your web page?
You can include Vue in your web page in any of the following ways:
- Referring the Vue from the following CDN
<script src="https://cdn.jsdelivr.net/npm/vue@2.5.21/dist/vue.js"></script>
- Intall using NPM
- Using the Vue CLI tool with WebPack
What is Vue CLI tool?
It is a npm pacakge npm package and allows using the vue command in terminal or command line.It allows to quickly create a Vue project using project scaffolding.To create a new project using the CLI use the following command vue create projectName
How do you include Vue in your web page?
To use Vue functionality in your application we need to create a vue instance.In the following example we are creating a vue instance and assigning setting the el and data properties.
new Vue({ el: '#appName', data: { 'Hello Vue' } });
What are filters in VUE.js?
Vue.js allows us to create filters which can be used for applying text formatting.They are used to make the data presentable to the user.
To use a filter we use the pipe character before the filter name.In the following example we are applying the filter filterName to the Expression expression.
{{Expression | filterName}}
We register a filter globally or locally.To create filter locally assign the filter method to filter property:
filters: { boolean: booleanFilter },
You can create a global filter as:
Vue.filter('filterName', function(value) { return//data });
What are components?
Vue application consists of collection of components.
We can create a component as:
Vue.component('componentName', { template: ` <h1>First Component</h1> ` });
We can use it in HTML as:
<component-name></component-name>
How Vue js handles routes?
Vue js handles routes using vue-router library.This is the official router for Vue.js