12. 开发论坛帖子展示功能

150 字约 1 分钟读完220 次阅读更新于 2026/5/3

https://www.yuque.com/xiaqing-en2ii/skflxg/hzi02h8qfizne3yv

GlobalArticle.vue

ArticleDetail.vue

<template>
  <div class="card" style="width: 60%; margin:  0 auto; padding: 50px; position: relative">
    <el-button @click="router.back()" style="position: absolute; top: 10px; left: 10px">返回论坛列表</el-button>
    <div style="font-size: 28px; font-weight: bold; text-align: center; margin-bottom: 15px">{{ data.article.title }}</div>
    <div style="font-size: 14px; color: #666; text-align: center; margin-bottom: 30px">发布人:{{ data.article.userName }}   <span style="margin-left: 20px">发布时间:{{ data.article.time }}</span></div>
    <div v-html="data.article.content"></div>
  </div>
</template>

<script setup>
import { reactive } from "vue";
import request from "@/utils/request";
import router from "@/router";

const data = reactive({
  user: JSON.parse(localStorage.getItem('xm-user') || '{}'),
  id: router.currentRoute.value.query.id,
  article: {}
})

request.get('/article/selectById/' + data.id).then(res => {
  data.article = res.data
})
</script>