深色模式
CodeCompare 代码比对
代码比对,用于比对两个代码片段之间的差异。
基本用法
点击查看代码
vue
<template>
<vue-code-compare v-model:leftValue="leftText" v-model:rightValue="rightText" style="height: 210px;" border/>
</template>
<script setup lang="ts">
import { ref } from "vue";
const leftText = ref<string>(
"const count = 0;\n\n" +
"const increase = () => {\n" +
" count++;\n" +
"}\n"
);
const rightText = ref<string>(
"const count = 0;\n\n" +
"const increase = (): number => {\n" +
" count++;\n" +
" return count\n" +
"}\n"
);
</script>1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
只读预览
点击查看代码
vue
<template>
<vue-code-compare v-model:leftValue="leftText" v-model:rightValue="rightText" style="height: 210px;"
readonly hideRollbackGutter border footer />
</template>
<script setup lang="ts">
import { ref } from "vue";
const leftText = ref<string>(
"const count = 0;\n\n" +
"const increase = () => {\n" +
" count++;\n" +
"}\n"
);
const rightText = ref<string>(
"const count = 0;\n\n" +
"const increase = (): number => {\n" +
" count++;\n" +
" return count\n" +
"}\n"
);
</script>1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
使用装饰器
点击查看代码
vue
<template>
<vue-code-compare v-model:leftValue="leftText" v-model:rightValue="rightText" style="height: 210px;"
:decorations="compareDecorations" border />
</template>
<script setup lang="ts">
import { ref } from "vue";
const compareDecorations = ref<Record<string, any>[]>([{}]);
const leftText = ref<string>(
"const [[count]] = 0;\n\n" +
"const increase = () => {\n" +
" count++;\n" +
"}\n"
);
const rightText = ref<string>(
"const count = 0;\n\n" +
"const increase = (): number => {\n" +
" [[count]]++;\n" +
" return count\n" +
"}\n"
);
</script>1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24