Skip to content

Commit 024f9b6

Browse files
committed
docs: Supplement the readme case code
1 parent d6a0e4b commit 024f9b6

File tree

2 files changed

+13
-11
lines changed

2 files changed

+13
-11
lines changed

docs/components/demoPreview.vue

Lines changed: 11 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
<template>
22
<div class="demo-preview" :class="$props.name">
3-
<div class="demo-preview-head" v-if="$props.title">
3+
<div v-if="$props.title" class="demo-preview-head">
44
{{ $props.title }}
55
</div>
66
<div class="demo-preview-body">
@@ -23,8 +23,9 @@
2323

2424
<script>
2525
import { ref, onMounted } from "vue";
26+
2627
export default {
27-
name: "default",
28+
name: "Default",
2829
components: {},
2930
props: {
3031
title: {
@@ -46,11 +47,10 @@ export default {
4647
const tiggerShowCode = () => {
4748
showCode.value = !showCode.value;
4849
if (showCode.value) {
49-
viewDom.value.style.height =
50+
viewDom.value.style.height = `${
5051
document.querySelector(`.language-vue.${props.name} pre`)
51-
.clientHeight +
52-
2 +
53-
"px";
52+
.clientHeight + 2
53+
}px`;
5454
viewDom.value.style.borderTop = "1px solid #ddd";
5555
return;
5656
}
@@ -61,7 +61,7 @@ export default {
6161
const moveCodeContent = () => {
6262
demoContent.value = document.querySelector(`.demo-preview.${props.name}`);
6363
codeContent.value = document.querySelector(`.language-vue.${props.name}`);
64-
let demoControl = document.querySelector(
64+
const demoControl = document.querySelector(
6565
`.demo-preview.${props.name} .demo-preview-control`
6666
);
6767
if (!demoContent.value.contains(codeContent.value)) {
@@ -75,10 +75,10 @@ export default {
7575
7676
const copy = () => {
7777
if (copyStatus.value) return;
78-
var type = "text/plain";
79-
let text = codeContent.value.innerText;
80-
var blob = new Blob([text], { type });
81-
var data = [new ClipboardItem({ [type]: blob })];
78+
const type = "text/plain";
79+
const text = codeContent.value.innerText;
80+
const blob = new Blob([text], { type });
81+
const data = [new ClipboardItem({ [type]: blob })];
8282
navigator.clipboard.write(data).then(
8383
function (e) {
8484
copyStatus.value = true;

docs/index.md

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -62,6 +62,8 @@ app.use(GlobalCmComponent, { componentName: "customName" });
6262
<script>
6363
import Codemirror from "codemirror-editor-vue3";
6464
65+
// placeholder
66+
import "codemirror/addon/display/placeholder.js";
6567
// language
6668
import "codemirror/mode/javascript/javascript.js";
6769

0 commit comments

Comments
 (0)