Created
October 7, 2016 13:03
-
-
Save kevinruscoe/06ee541553cd5d2f310bd1db50d02193 to your computer and use it in GitHub Desktop.
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('People', require('./components/People.vue')); | |
Vue.component('Person', require('./components/Person.vue')); | |
const app = new Vue({ | |
el: '#app' | |
}); |
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
<html> | |
<head> | |
<meta http-equiv="Content-type" content="text/html; charset=utf-8"> | |
<title>index</title> | |
</head> | |
<body> | |
<div id="app"> | |
<People></People> | |
</div> | |
<script src="js/app.js" type="text/javascript" charset="utf-8"></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
<template> | |
<ul id="People"> | |
<Person v-for="(person, index) in people" | |
:name="person.name" | |
:age="person.age" | |
v-on:destroy="destroy" | |
></Person> | |
</ul> | |
</template> | |
<script> | |
export default { | |
data: function(){ | |
return { | |
people: [ | |
{ | |
name: "Kevin", | |
age: 28 | |
}, | |
{ | |
name: "Adam", | |
age: 24 | |
} | |
] | |
} | |
}, | |
methods: { | |
destroy: function(person){ | |
this.people.splice(person, 1); | |
} | |
} | |
} | |
</script> |
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
<template> | |
<li @click="destroy"> | |
{{ name }} {{ age }} | |
</li> | |
</template> | |
<script> | |
export default { | |
props: ['name', 'age'], | |
methods: { | |
destroy: function(){ | |
this.$emit('destroy', this); | |
} | |
} | |
} | |
</script> |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment