Feature: 页面内Markdown渲染 & 规格参数表格
This commit is contained in:
36
app/components/MarkdownRenderer.vue
Normal file
36
app/components/MarkdownRenderer.vue
Normal file
@ -0,0 +1,36 @@
|
||||
<!-- 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>()
|
||||
|
||||
// 将 Markdown 转换成 HTML
|
||||
const safeHtml = computed(() => renderMarkdown(props.content))
|
||||
console.log('Markdown content:', safeHtml.value)
|
||||
</script>
|
||||
|
||||
<style>
|
||||
.markdown-body {
|
||||
padding: 10px;
|
||||
line-height: 1.6;
|
||||
}
|
||||
|
||||
.markdown-body h1,
|
||||
.markdown-body h2 {
|
||||
color: var(--el-color-primary);
|
||||
font-size: 1.5em;
|
||||
margin-bottom: 0.5em;
|
||||
}
|
||||
|
||||
.markdown-body ol {
|
||||
list-style-type: decimal;
|
||||
padding-left: 2em;
|
||||
}
|
||||
</style>
|
||||
Reference in New Issue
Block a user