A Vue.js method is a function associated with the Vue.js instance. Methods are defined inside the `methods` property.
Let’s see how they work.
Methods are defined inside the methods property:
Syntax:
export default { methods: { // We can add our functions here } }
Example:
<template> <a @v-on:click="handleClick">Click me!</a> </template> <script> export default{ methods : { handleClick: function(){ return alert("methods example of vue.js"); } } } </script>
<template> <a v-on:click="handleClick('Hey this is example of methods property')">Click me!</a> </template> <script> export default { methods: { handleClick: function(data) { return alert(data); } } } </script>
<template> <div id="methodExample"> <h3>Name:{{name}}</h3> <h4>Topic:{{topic}}</h4> <button v-on:click="onClick">Go to Example</button> </div> </template> <script> export default{ name : 'methodExample', data : function(){ return{ name :'Methods Example', title :'Vue.js' } }, methods : { onClick : function(){ return alert("Hey! This is" + this.name + "of" + this.title); } } } </script>
For accessing the variables, we don’t have to use this.data.name, just this.name. Vue.js does provide a transparent binding for us. Using this.data.name will raise an error.
In this article, we have to show Create and Used PIPE in angular
In this article, we have to show Create and Used PIPE in angular
In this article, we have to show Create and Used PIPE in angular