Skip to content

Instantly share code, notes, and snippets.

@fjugaldev
Created April 14, 2020 12:38
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save fjugaldev/55b6540756280c10b9a4b3ef38d613b8 to your computer and use it in GitHub Desktop.
Save fjugaldev/55b6540756280c10b9a4b3ef38d613b8 to your computer and use it in GitHub Desktop.
<!DOCTYPE html>
<html>
<head>
<title>Desde Cero: Cromo crear un componente en Vue.js</title>
<!-- Incluimos Vue.js desde CDN -->
<script src="https://cdn.jsdelivr.net/npm/vue"></script>
</head>
<body>
<div id="app">
<ul>
<!-- Ahora le pasamos a cada newsletter-users la propiedad email -->
<!-- que representa un objeto cuyo contenido dinámico proviene del array
de objetos registerdUsers -->
<newsletter-users v-for="user in registeredUsers" v-bind:email="user"></newsletter-users>
</ul>
</div>
<script>
Vue.component('newsletter-users', {
props: ['email'],
template: '<li>{{ email.text }}</li>'
})
var app = new Vue({
el: '#app',
data: {
registeredUsers: [
{ text: 'usuario1@franciscougalde.com' },
{ text: 'usuario2@franciscougalde.com' },
{ text: 'usuario3@franciscougalde.com' },
{ text: 'usuario4@franciscougalde.com' },
{ text: 'usuario5@franciscougalde.com' }
]
}
});
</script>
</body>
</html>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment