-
Notifications
You must be signed in to change notification settings - Fork 10
/
newsInfo.vue
78 lines (71 loc) · 1.53 KB
/
newsInfo.vue
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
<template>
<div>
<div class="newsinfo-container">
<h3 class="title">{{ newsinfo.title }}</h3>
<p class="subtitle">
<span>{{ newsinfo.add_time | dateFormat }}</span>
<span>点击: {{ newsinfo.click }} 次</span>
</p>
<hr>
<!-- 内容区域 -->
<div class="content" v-html="newsinfo.content"></div>
<!-- 评论子组件区域 -->
<comment-box :id="this.id"></comment-box>
</div>
</div>
</template>
<script>
// 1、导入评论子组件
import comment from '../subcomments/comment.vue'
import { Toast } from 'mint-ui'
export default {
data() {
return {
// 将 URL 地址中传递过来的 id 值挂载到 data上,方便以后调用
id: this.$route.params.id,
newsinfo: {}
}
},
created() {
this.getNewsInfo()
},
methods: {
getNewsInfo() {
// 获取新闻详情
this.$http.get('api/getnew/' + this.id).then(result => {
if (result.body.status === 0) {
this.newsinfo = result.body.message[0]
} else {
Toast('获取新闻详情失败')
}
})
}
},
// 2、注册评论组件
components: {
'comment-box': comment
}
}
</script>
<style lang="scss" scoped>
.newsinfo-container {
padding: 0 4px;
.title {
font-size: 16px;
text-align: center;
margin: 15px 0;
color: red;
}
.subtitle {
font-size: 13px;
color: #226aff;
display: flex;
justify-content: space-between;
}
.content {
img {
width: 100%;
}
}
}
</style>