File tree 1 file changed +22
-4
lines changed
1 file changed +22
-4
lines changed Original file line number Diff line number Diff line change 2
2
<div class =" page_article" >
3
3
<header class =" header" >
4
4
<h1 class =" title" >
5
- {{ article.title }} + {{ this.$route.params.id }}
5
+ {{ article.title }}
6
6
</h1 >
7
7
<p class =" desc" >
8
- {{ article.description }}
9
8
</p >
10
9
</header >
11
- <article class =" content" >
12
- 这里面是内容
10
+ <article class =" content" v-html =" article.content" >
13
11
</article >
14
12
</div >
15
13
</template >
16
14
17
15
<script >
18
16
import Vue from ' vue'
17
+ import { articleDetail } from ' ../api/commont'
19
18
20
19
export default Vue .extend ({
21
20
name: ' Article' ,
22
21
data () {
23
22
return {
23
+ articleId: null ,
24
24
article: {
25
25
author: {
26
26
avatar: ' http://img1.3lian.com/gif/more/11/2012/03/d037a77443c0a72a1432d815cd3b5724.jpg' ,
@@ -34,6 +34,24 @@ export default Vue.extend({
34
34
cover: ' '
35
35
}
36
36
}
37
+ },
38
+ created () {
39
+ // 页面创建时取到文章的ID
40
+ this .articleId = this .$route .params .id
41
+ // 获取文章详情
42
+ this .getDetail (this .articleId )
43
+ },
44
+ methods: {
45
+ getDetail (id ) {
46
+ articleDetail (id).then ((res ) => {
47
+ console .log (res)
48
+ if (res .code === 0 ) {
49
+ this .article = res .data .article
50
+ } else {
51
+ console .log (res .msg )
52
+ }
53
+ })
54
+ }
37
55
}
38
56
})
39
57
</script >
You can’t perform that action at this time.
0 commit comments