-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy path21-main.js
30 lines (28 loc) · 854 Bytes
/
21-main.js
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
Vue.component('lista-usuarios',{props: ['datos'],
template: `<div><strong> <slot></slot></strong><ul><li v-for="u in datos">Nombre: {{u.name}}, <dir-usuario :dirdata="u.address"></dir-usuario></li></ul></div>`
});
Vue.component('dir-usuario',{props: ['dirdata'],
template: `<span> Ciudad:
<span class="icon">
<i class="fas fa-home"></i>
</span> {{dirdata.city}} </span>`
});
new Vue({
el: 'main',
mounted() {
this.obtenerUsuarios();
},
data: {
usuarios: [],
},
methods: {
obtenerUsuarios() {
axios.get('https://jsonplaceholder.typicode.com/users')
.then((respuesta) => {
this.usuarios = respuesta.data;
//console.log(respuesta);
console.log(this.usuarios);
});
}
}
});