The Vue.js is a
progressive JavaScript framework and used to building the interactive user
interfaces and also it’s focused on the view layer only (front end).
The Vue.js is easy to integrate with other libraries and
others existing projects. Vue.js is very popular for Single
Page Applications developments.
The Vue.js is lighter,
smaller in size and so faster. It also supports the MVVM (Model-View-ViewModel)
pattern.
How To CREATE Custom Filters in Vue.js 2?
HTML Code –
<script src="https://unpkg.com/vue"></script>
<div id="demo-app">
<ul>
<li v-for="customer in customers">
{{customer.id}} {{ customer.name }} and Age Are ({{customer.age}}) Years
</li>
<ul>
<div>
VueJs Code –
//Model class
var customerModel = {
name: "Anil Singh",
age: 32,
customers: [
{ id:1, name: "code-sample.com", age: 5400 },
{ id:2, name: "code-sample.xyz", age: 4540 },
{ id:3, name: "code-view.com", age: 4520 }
]
};
//Customer View Model.
var customerViewModel = new Vue({
el: '#demo-app',
data: customerModel
});
The result looks here – https://jsfiddle.net/ofubzd6w/
How To Use filters in Vue.js 2?
HTML Code –
<script src="https://unpkg.com/vue"></script>
<div id="demo-app">
<label>Enter name </label>
<input type="text" v-model="name" id="name" name="name" />
<h4>My Name is - {{ name }} and my age is - {{ age }} years. </h4>
</div>
VueJs Code –
//Model class
var userModel = {
id:1,
name: "Anil Singh",
age: 24
};
//View Model Class
var userViewModel = new Vue({
el: '#demo-app',
data: userModel
});
Result looks here - https://jsfiddle.net/r6hhcvg7/
I hope you are enjoying with this post! Please share with you friends. Thank you!!