Created
June 16, 2017 04:30
-
-
Save srkama/e55f2884d08ade616bc5b3028e2822d5 to your computer and use it in GitHub Desktop.
JS Bin // source http://jsbin.com/yidoseh
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
<!DOCTYPE html> | |
<html> | |
<head> | |
<meta charset="utf-8"> | |
<meta name="viewport" content="width=device-width"> | |
<title>JS Bin</title> | |
<script src="https://unpkg.com/vue"></script> | |
</head> | |
<body> | |
<div id="app"> | |
<user-name v-bind:username="'kamala'" v-on:userclicked="printUser($event)"></user-name> | |
<user-name v-bind:username="'kamalak'"></user-name> | |
<user-name v-bind:username="'kamal'"></user-name> | |
<user-name v-bind:username="'kamalaka'"></user-name> | |
<span>{{name}}</span> | |
<div v-if="name != 'kamal'">this got changed</div> | |
<button v-on:click="changeName">Change</button> | |
<button v-on:click="addElement">New</button> | |
<ul> | |
<li v-for="element in elements" v-bind:id="'el' + element" v-bind:style="{backgroundColor:'Green'}"> {{ element }} </li> | |
</ul> | |
</div> | |
<script id="jsbin-javascript"> | |
Vue.component('user-name', { | |
props: ['username'], | |
data: function(){ | |
return { | |
} | |
}, | |
template:"<h1 v-on:click='usernameClicked'>{{ username}} </h1>", | |
methods: { | |
usernameClicked: function() { | |
this.$emit('userclicked', this.username); | |
} | |
} | |
}); | |
new Vue({ | |
el:"#app", | |
data: { | |
name:"kamal", | |
elements: [] | |
}, | |
methods: { | |
changeName: function() { | |
this.name = "kannan"; | |
}, | |
addElement: function() { | |
this.elements.push(this.elements.length+1) | |
}, | |
printUser: function(data) { | |
console.log(data); | |
} | |
} | |
}); | |
</script> | |
<script id="jsbin-source-javascript" type="text/javascript">Vue.component('user-name', { | |
props: ['username'], | |
data: function(){ | |
return { | |
} | |
}, | |
template:"<h1 v-on:click='usernameClicked'>{{ username}} </h1>", | |
methods: { | |
usernameClicked: function() { | |
this.$emit('userclicked', this.username); | |
} | |
} | |
}); | |
new Vue({ | |
el:"#app", | |
data: { | |
name:"kamal", | |
elements: [] | |
}, | |
methods: { | |
changeName: function() { | |
this.name = "kannan"; | |
}, | |
addElement: function() { | |
this.elements.push(this.elements.length+1) | |
}, | |
printUser: function(data) { | |
console.log(data); | |
} | |
} | |
});</script></body> | |
</html> |
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
Vue.component('user-name', { | |
props: ['username'], | |
data: function(){ | |
return { | |
} | |
}, | |
template:"<h1 v-on:click='usernameClicked'>{{ username}} </h1>", | |
methods: { | |
usernameClicked: function() { | |
this.$emit('userclicked', this.username); | |
} | |
} | |
}); | |
new Vue({ | |
el:"#app", | |
data: { | |
name:"kamal", | |
elements: [] | |
}, | |
methods: { | |
changeName: function() { | |
this.name = "kannan"; | |
}, | |
addElement: function() { | |
this.elements.push(this.elements.length+1) | |
}, | |
printUser: function(data) { | |
console.log(data); | |
} | |
} | |
}); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment