File tree Expand file tree Collapse file tree 3 files changed +43
-2
lines changed Expand file tree Collapse file tree 3 files changed +43
-2
lines changed Original file line number Diff line number Diff line change 3
3
<h1 >All Blog Articles</h1 >
4
4
<input type =" text" v-model =" search" placeholder =" search blogs" />
5
5
<div v-for =" blog in filteredBlogs" class =" single-blog" >
6
- <h2 >{{ blog.title }}</h2 >
6
+ <router-link v-bind:to = " '/blog/' + blog.id " >< h2 >{{ blog.title }}</h2 ></ router-link >
7
7
<article >{{ blog.body }}</article >
8
8
</div >
9
9
</div >
@@ -40,4 +40,9 @@ export default {
40
40
box-sizing : border-box ;
41
41
background : #eee ;
42
42
}
43
+
44
+ #show-blogs a {
45
+ color : #444 ;
46
+ text-decoration : none ;
47
+ }
43
48
</style >
Original file line number Diff line number Diff line change
1
+ <template >
2
+ <div id =" single-blog" >
3
+ <h1 >{{ blog.title }}</h1 >
4
+ <article >{{ blog.body }}</article >
5
+ </div >
6
+ </div >
7
+ </template >
8
+
9
+ <script >
10
+ // Imports
11
+ import searchMixin from ' ../mixins/searchMixin' ;
12
+
13
+ export default {
14
+ data () {
15
+ return {
16
+ id: this .$route .params .id ,
17
+ blog: {}
18
+ }
19
+ },
20
+ created () {
21
+ this .$http .get (' http://jsonplaceholder.typicode.com/posts/' + this .id ).then (function (data ){
22
+ // console.log(data);
23
+ this .blog = data .body ;
24
+ });
25
+ }
26
+ }
27
+ </script >
28
+
29
+ <style >
30
+ #single-blog {
31
+ max-width : 960px ;
32
+ margin : 0 auto ;
33
+ }
34
+ </style >
Original file line number Diff line number Diff line change 1
1
import addBlog from './components/addBlog.vue' ;
2
2
import showBlogs from './components/showBlogs.vue' ;
3
+ import singleBlog from './components/singleBlog.vue' ;
3
4
4
5
export default [
5
6
{ path : '/' , component : showBlogs } ,
6
- { path : '/add' , component : addBlog }
7
+ { path : '/add' , component : addBlog } ,
8
+ { path : '/blog/:id' , component : singleBlog }
7
9
]
You can’t perform that action at this time.
0 commit comments