Created
October 23, 2017 05:38
-
-
Save aayushdrolia/d6cc4c30f60aa1c372ac566026180b22 to your computer and use it in GitHub Desktop.
Event Listeners with Vue js
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// 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