Files
jinshen-website/app/components/MarkdownRenderer.vue
R2m1liA f957adfa5d feat: 完成网站前端的基本建设
- 网站内容展示:首页, 产品页, 解决方案, 联系信息等
- 网站跳转逻辑:通过Vue-Router实现路由跳转
- 后端通信: 通过Nuxt Strapi与后端Strapi服务进行通信
2025-09-06 15:59:52 +08:00

73 lines
1.3 KiB
Vue

<!-- eslint-disable vue/no-v-html -->
<template>
<!-- v-html 渲染解析后的 HTML -->
<div class="markdown-body" v-html="safeHtml" />
</template>
<script setup lang="ts">
interface Props {
content: string
}
const props = defineProps<Props>()
const contentWithAbsoluteUrls = convertMedia(props.content)
// 将 Markdown 转换成 HTML
const safeHtml = computed(() => renderMarkdown(contentWithAbsoluteUrls))
// const safeHtml = computed(() => renderMarkdown(props.content))
console.log('Rendered HTML:', safeHtml.value)
</script>
<style>
.markdown-body {
padding: 10px;
line-height: 1.6;
}
.markdown-body h1 {
color: var(--el-color-primary);
font-size: 1.5em;
margin-bottom: 0.5em;
text-align: center;
}
.markdown-body h2 {
color: var(--el-color-primary);
font-size: 1.5em;
margin-bottom: 0.5em;
}
.markdown-body h3 {
color: var(--el-color-primary);
font-size: 1.2em;
margin-bottom: 0.5em;
}
.markdown-body p {
text-indent: 2em;
text-align: justify;
margin: 0.5em 0;
margin-bottom: 1em;
}
.markdown-body ol {
list-style-type: decimal;
padding-left: 2em;
margin-bottom: 1em;
}
.markdown-body ul {
list-style-type: disc;
padding-left: 2em;
margin-bottom: 1em;
}
.markdown-body hr {
border: none;
border-top: 1px solid var(--el-border-color);
margin: 20px 0;
}
</style>