-
Notifications
You must be signed in to change notification settings - Fork 13
/
Copy pathcomponent.html
77 lines (73 loc) · 1.85 KB
/
component.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
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
<!DOCTYPE html>
<html lang="es">
<head>
<meta charset="UTF-8">
<title>VUEjs V2 Component | 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>Album</h1>
<common-list v-bind:lists="albums"></common-list>
</div>
<div class="col-sm-4">
<h1>Posts</h1>
<common-list v-bind:lists="posts"></common-list>
</div>
<div class="col-sm-4">
<h1>Photos</h1>
<common-list v-bind:lists="photos"></common-list>
</div>
<div class="col-sm-12">
<h1>JSON</h1>
<pre>
{{ $data }}
</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/axios/0.16.1/axios.min.js"></script>
<script type="text/javascript">
Vue.component('common-list',{
props : ['lists'],
template : `<ul class="list-group">
<li v-for="item in lists" class="list-group-item">
{{ item.title }}
</li>
</ul>`,
});
var urlPosts = 'https://jsonplaceholder.typicode.com/posts';
var urlAlbums = 'https://jsonplaceholder.typicode.com/albums';
new Vue({
el: '#main',
created: function() {
this.getPosts(),
this.getAlbums()
},
data: {
posts: [],
albums: [],
photos: [
{title: 'foto 1'},
{title: 'foto 2'},
]
},
methods: {
getPosts: function() {
axios.get(urlPosts).then(response => {
this.posts = response.data
});
},
getAlbums: function() {
axios.get(urlAlbums).then(response => {
this.albums = response.data
});
}
}
});
</script>
</body>
</html>