-
Notifications
You must be signed in to change notification settings - Fork 13
/
Copy pathajax.html
51 lines (50 loc) · 1.33 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
<!DOCTYPE html>
<html lang="es">
<head>
<meta charset="UTF-8">
<title>VUEjs V2 AJAX vue-resource | Rimorsoft Online</title>
<link rel="stylesheet" href="https://maxcdn.bootstrapcdn.com/bootstrap/3.3.7/css/bootstrap.min.css" integrity="sha384-BVYiiSIFeK1dGmJRAkycuHAHRg32OmUcww7on3RYdg4Va+PmSTsz/K68vbdEjh4u" crossorigin="anonymous">
</head>
<body>
<div id="main" class="container">
<div class="row">
<div class="col-sm-4">
<h1>Lista VUEjs - AJAX</h1>
<ul class="list-group">
<li v-for="item in lists" class="list-group-item">
{{ item.name }}
</li>
</ul>
</div>
<div class="col-sm-8">
<h1>JSON</h1>
<pre>
{{ $data | json }}
</pre>
</div>
</div>
</div>
<script src="https://cdnjs.cloudflare.com/ajax/libs/vue/2.2.0/vue.js"></script>
<script src="https://cdnjs.cloudflare.com/ajax/libs/vue-resource/1.3.1/vue-resource.min.js"></script>
<script type="text/javascript">
//var urlUsers = 'https://randomuser.me/api/?results=10';
var urlUsers = 'https://jsonplaceholder.typicode.com/users';
new Vue({
el: '#main',
created: function() {
this.getUsers();
},
data: {
lists: []
},
methods: {
getUsers: function() {
this.$http.get(urlUsers).then(function(response){
this.lists = response.data;
});
}
}
});
</script>
</body>
</html>