File tree Expand file tree Collapse file tree 2 files changed +43
-3
lines changed Expand file tree Collapse file tree 2 files changed +43
-3
lines changed Original file line number Diff line number Diff line change 1
1
<template >
2
2
<div >
3
- <add-blog ></add-blog >
3
+ <show-blogs ></show-blogs >
4
4
</div >
5
5
</template >
6
6
7
7
<script >
8
8
// Imports
9
- import addBlog from ' ./components/addBlog .vue' ;
9
+ import showBlogs from ' ./components/showBlogs .vue' ;
10
10
11
11
export default {
12
12
components: {
13
- ' add-blog ' : addBlog
13
+ ' show-blogs ' : showBlogs
14
14
},
15
15
data () {
16
16
return {
Original file line number Diff line number Diff line change
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 >
You can’t perform that action at this time.
0 commit comments