Files
timi-web/docs/demos/markdown-view/basic.vue
T
2026-09-21 15:32:12 +08:00

49 lines
904 B
Vue

<template>
<div class="demo">
<markdown-view :content="content" max-height="24rem" />
<markdown-view :code="code" max-height="16rem" />
</div>
</template>
<script lang="ts" setup>
import { MarkdownView } from "timi-web";
const content = `## Markdown 渲染
支持标题、列表、表格与代码块的完整渲染:
- 无序列表
- **加粗**、*斜体*、\`行内代码\`
| 参数 | 说明 |
| --- | --- |
| content | Markdown 原文 |
| code | 单段代码,形如 \`lang:code\` |
\`\`\`typescript
const answer: number = 42;
\`\`\`
`;
/** 传 code 时按「语言:正文」解析,用于只展示一段代码的场景。 */
const code = `typescript:interface User {
id: string;
name: string;
}
const user: User = { id: "u1", name: "Timi" };`;
</script>
<style lang="less" scoped>
.demo {
> div {
margin-bottom: 1.5rem;
&:last-child {
margin-bottom: 0;
}
}
}
</style>