iter(g270): 新增代码块组件
This commit is contained in:
@@ -24,6 +24,7 @@ import {
|
||||
cascader,
|
||||
checkbox,
|
||||
checkboxGroup,
|
||||
codeBlock,
|
||||
colorPicker,
|
||||
timePicker,
|
||||
commandPalette,
|
||||
@@ -1765,6 +1766,24 @@ const content = h(
|
||||
].join('\n'),
|
||||
}),
|
||||
),
|
||||
section(
|
||||
'sec-code',
|
||||
'代码块',
|
||||
'codeBlock:等宽多行 + 行号列 + 头部标题,右上角一键复制原文;行号是装饰、不进剪贴板,只做展示不高亮。',
|
||||
codeBlock({
|
||||
title: 'sum.ts',
|
||||
lang: 'ts',
|
||||
maxHeight: 200,
|
||||
code: [
|
||||
'export function sum(a: number, b: number): number {',
|
||||
' if (typeof a !== \'number\') throw new TypeError(\'a 必须是数字\');',
|
||||
' return a + b;',
|
||||
'}',
|
||||
'',
|
||||
'// 用法:sum(1, 2) === 3',
|
||||
].join('\n'),
|
||||
}),
|
||||
),
|
||||
);
|
||||
|
||||
// 悬浮按钮:fixed 定位,挂 body 不参与页面布局
|
||||
|
||||
Reference in New Issue
Block a user