Skip to content

Instantly share code, notes, and snippets.

@aayushdrolia
Created October 23, 2017 05:38
Show Gist options
  • Save aayushdrolia/d6cc4c30f60aa1c372ac566026180b22 to your computer and use it in GitHub Desktop.
Save aayushdrolia/d6cc4c30f60aa1c372ac566026180b22 to your computer and use it in GitHub Desktop.
Event Listeners with Vue js
// Create your html structure
<div id= "root">
<input type= "text" id= "input">
<button v-on:click= "addname" >AddName</button>
</div>
OR
<div id= "root">
<input type= "text" id= "input">
<button @click= "addName" >AddName</button>
</div>
// js code
<script>
let app1 = new Vue({
el: "#root",
data: {
message: "Hello World"
}
methods:{
addName(){
alert('adding name');
}
}
})
</script>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment