This repository was archived by the owner on Oct 21, 2020. It is now read-only.
forked from lorranpalmeira/VueJs
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathaula-19-ajax-axios.html
More file actions
56 lines (49 loc) · 1.37 KB
/
aula-19-ajax-axios.html
File metadata and controls
56 lines (49 loc) · 1.37 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
54
55
56
<!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://unpkg.com/vue"></script>
<script src="https://unpkg.com/axios/dist/axios.min.js"></script>
<script>
var mixin = {
methods:{
getUsers(){
//this.load.users = true;
var url = 'https://jsonplaceholder.typicode.com/users';
var vm = this;
axios.get(url).then(function(response){
console.log(response);
vm.users = response.data;
//vm.load.users = false;
});
}
}
}
var app = new Vue({
el:"#app",
mixins: [mixin],
data:{
titulo:"VueJs Jeito Ninja",
users:[],
response:{
msg:"Erro Ao conectar",
Status:''
}
}
});
</script>