Skip to content

Commit be60e89

Browse files
authored
Merge pull request #23 from studygolang/isColt
Is colt
2 parents 9007173 + 81e370f commit be60e89

File tree

1 file changed

+22
-4
lines changed

1 file changed

+22
-4
lines changed

src/article/Index.vue

+22-4
Original file line numberDiff line numberDiff line change
@@ -2,25 +2,25 @@
22
<div class="page_article">
33
<header class="header">
44
<h1 class="title">
5-
{{ article.title }} + {{ this.$route.params.id }}
5+
{{ article.title }}
66
</h1>
77
<p class="desc">
8-
{{ article.description }}
98
</p>
109
</header>
11-
<article class="content">
12-
这里面是内容
10+
<article class="content" v-html="article.content">
1311
</article>
1412
</div>
1513
</template>
1614

1715
<script>
1816
import Vue from 'vue'
17+
import { articleDetail } from '../api/commont'
1918
2019
export default Vue.extend({
2120
name: 'Article',
2221
data() {
2322
return {
23+
articleId: null,
2424
article: {
2525
author: {
2626
avatar: 'http://img1.3lian.com/gif/more/11/2012/03/d037a77443c0a72a1432d815cd3b5724.jpg',
@@ -34,6 +34,24 @@ export default Vue.extend({
3434
cover: ''
3535
}
3636
}
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+
}
3755
}
3856
})
3957
</script>

0 commit comments

Comments
 (0)