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
| <template>
| <!-- 此文件路径禁止移动 -->
| <view>
| <view class="container ">
| <view class="u-skeleton" v-if="!articleData">
| <u-empty text="文章暂无内容" mode="list"></u-empty>
| </view>
| <u-parse v-else :html="articleData"></u-parse>
| </view>
| </view>
| </template>
|
| <script>
| import '@/uview-components/uview-ui'
| import { getArticleDetail } from "@/api/article.js";
| export default {
| data() {
| return {
| // 用于接收上一级通过路径传输的数据
| routers: "",
| // 请求文章接口后存储文章信息
| articleData: "",
| };
| },
| onLoad(val) {
| this.routers = val;
| getArticleDetail(val.id).then((res) => {
| if (res.data.result) {
| // 将请求的文章数据赋值
| this.articleData = res.data.result.content;
| }
| // 修改当前NavigationBar(标题头)为文章头部
| uni.setNavigationBarTitle({
| title: val.title,
| });
| });
| },
| };
| </script>
| <style lang="scss" scoped>
| page {
| background: #fff;
| }
| .container {
| padding: 32rpx;
| > p {
| margin: 20rpx;
| }
| }
| </style>
|
|