Skip to content

Commit 476cb4a

Browse files
author
Shaun Pelling
committed
added lesson 33 code
1 parent 10c64db commit 476cb4a

File tree

2 files changed

+43
-3
lines changed

2 files changed

+43
-3
lines changed

src/App.vue

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,16 +1,16 @@
11
<template>
22
<div>
3-
<add-blog></add-blog>
3+
<show-blogs></show-blogs>
44
</div>
55
</template>
66

77
<script>
88
// Imports
9-
import addBlog from './components/addBlog.vue';
9+
import showBlogs from './components/showBlogs.vue';
1010
1111
export default {
1212
components: {
13-
'add-blog': addBlog
13+
'show-blogs': showBlogs
1414
},
1515
data () {
1616
return {

src/components/showBlogs.vue

Lines changed: 40 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,40 @@
1+
<template>
2+
<div id="show-blogs">
3+
<h1>All Blog Articles</h1>
4+
<div v-for="blog in blogs" class="single-blog">
5+
<h2>{{ blog.title }}</h2>
6+
<article>{{ blog.body }}</article>
7+
</div>
8+
</div>
9+
</template>
10+
11+
<script>
12+
export default {
13+
data () {
14+
return {
15+
blogs: []
16+
}
17+
},
18+
methods: {
19+
20+
},
21+
created() {
22+
this.$http.get('http://jsonplaceholder.typicode.com/posts').then(function(data){
23+
this.blogs = data.body.slice(0,10);
24+
});
25+
}
26+
}
27+
</script>
28+
29+
<style>
30+
#show-blogs{
31+
max-width: 800px;
32+
margin: 0px auto;
33+
}
34+
.single-blog{
35+
padding: 20px;
36+
margin: 20px 0;
37+
box-sizing: border-box;
38+
background: #eee;
39+
}
40+
</style>

0 commit comments

Comments
 (0)