带语言标签与复制按钮的代码展示组件。
export function hello(name: string) {
return `Hello, ${name}`
}<script setup lang="ts">
import { DanCodeBlock } from '@dandan-ui/ui'
const code = `export function hello(name: string) {
return \`Hello, \${name}\`
}`
</script>
<template>
<DanCodeBlock language="ts" :code="code" />
</template>| 属性 | 说明 | 类型 | 默认值 | 必填 |
|---|---|---|---|---|
| code | 代码文本 | string | '' | 否 |
| language | 语言标签展示名,如 ts / vue | string | '' | 否 |
无。复制使用浏览器 clipboard API,失败时静默忽略。
无。