-
Notifications
You must be signed in to change notification settings - Fork 1
Expand file tree
/
Copy pathaula-18-ajax-vue-resource.html
More file actions
53 lines (49 loc) · 1.36 KB
/
Copy pathaula-18-ajax-vue-resource.html
File metadata and controls
53 lines (49 loc) · 1.36 KB
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
<!DOCTYPE html>
<html lang="en">
<head>
<link rel="stylesheet" href="https://maxcdn.bootstrapcdn.com/bootstrap/3.3.7/css/bootstrap.min.css"/>
<meta charset="UTF-8">
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<meta http-equiv="X-UA-Compatible" content="ie=edge">
<title>Document</title>
</head>
<body>
<div id="app">
<h1>{{titulo}}</h1>
<button @click.stop.prevent="getUsers()" class="btn btn-success">Get User</button>
<ul>
<li v-for="user in users">{{user.name}}</li>
</ul>
</div>
</body>
</html>
<script src="https://cdn.jsdelivr.net/npm/vue-resource@1.3.4"></script>
<script src="https://unpkg.com/vue"></script>
<script>
var mixin = {
methods:{
getUsers(){
var url = 'https://jsonplaceholder.typicode.com/users';
this.$http.get(url)
.then(function(response){
console.log(response);
this.users = response.body;
},function(error){
console.log('error: ' + error);
});
}
}
}
var app = new Vue({
el:"#app",
mixins: [mixin],
data:{
titulo:"VueJs Jeito Ninja",
users:[],
response:{
msg:"Erro Ao conectar",
Status=''
}
}
});
</script>