-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathajax.html
54 lines (50 loc) · 1.41 KB
/
ajax.html
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
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
<!doctype html>
<html lang="en">
<head>
<!-- Required meta tags -->
<meta charset="utf-8">
<meta name="viewport" content="width=device-width, user-scalable=no, initial-scale=1, maximun-scale=1, minimun-scale=1">
<meta http-equiv="X-UA-Compatible" content="ie=edge">
<title>Ajax</title>
</head>
<body>
<main id="app">
<table>
<th>Nombre</th>
<th>Email</th>
<th>Ciudad</th>
<th>Localización</th>
<tr v-for="item in datos">
<td>{{item.name}}</td>
<td>{{item.email}}</td>
<td>{{item.address.city}}</td>
<td>Lat: {{item.address.geo.lat}} Long: {{item.address.geo.lng}}</td>
</tr>
</table>
<br>
<pre>{{$data}}</pre> <!-- En versión anterior, la sintaxis era {{$data | json}} -->
</main>
<script src="vueJS/vue.min.js"></script>
<script src="https://cdnjs.cloudflare.com/ajax/libs/vue-resource/1.5.1/vue-resource.min.js"></script>
<script>
const url = 'https://jsonplaceholder.typicode.com/users'
const app = new Vue({
el:'#app',
data:{
datos: []
},
created(){
this.usuarios()
},
methods:{
usuarios(){
this.$http.get(url)
.then(function(respuesta){
this.datos = respuesta.data
})
}
}
})
</script>
</body>
</html>