iter(g269): 新增文本差异对比组件
This commit is contained in:
@@ -37,6 +37,7 @@ import {
|
||||
datePicker,
|
||||
transfer,
|
||||
descriptions,
|
||||
diffView,
|
||||
divider,
|
||||
drawer,
|
||||
empty,
|
||||
@@ -1739,6 +1740,31 @@ const content = h(
|
||||
maxHeight: 260,
|
||||
}),
|
||||
),
|
||||
section(
|
||||
'sec-diff',
|
||||
'文本差异对比',
|
||||
'diffView:改前 / 改后整串丢进去——先剪公共前后缀再对中间段做 LCS,所以改两行不会把整篇标红;增删行同时有底色与 + / − 符号两条通道。',
|
||||
diffView({
|
||||
before: [
|
||||
'export function sum(a, b) {',
|
||||
' return a + b;',
|
||||
'}',
|
||||
'',
|
||||
'// 用法',
|
||||
'sum(1, 2);',
|
||||
].join('\n'),
|
||||
after: [
|
||||
'export function sum(a, b) {',
|
||||
" if (typeof a !== 'number') throw new TypeError('a 必须是数字');",
|
||||
' return a + b;',
|
||||
'}',
|
||||
'',
|
||||
'// 用法',
|
||||
'sum(1, 2);',
|
||||
"sum(1, '2');",
|
||||
].join('\n'),
|
||||
}),
|
||||
),
|
||||
);
|
||||
|
||||
// 悬浮按钮:fixed 定位,挂 body 不参与页面布局
|
||||
|
||||
Reference in New Issue
Block a user