0.1.14 • Published 7 months ago

vue-demo-editor v0.1.14

Weekly downloads
-
License
-
Repository
github
Last release
7 months ago

vue-demo-editor

项目功能 🔨

一个基于 vue-live 的 Vue 组件,用于实时编辑和演示组件。专为组件文档中轻松展示组件而设计。

特性

  • 自定义布局和样式,针对组件演示进行了优化
  • 增加切换显示源代码和复制代码按钮
  • 支持浅色和深色主题
  • 实时编辑组件演示代码
  • 轻松配置组件依赖
  • 复制成功回调函数
  • 使用 PrismJS 进行语法高亮

安装使用步骤

安装

你可以使用 npm 或 yarn 来安装 vue-demo-editor:

npm install vue-demo-editor
# 或者
yarn add vue-demo-editor

使用

<template>
  <vue-demo-editor
    :code="demoCode" 
    :components="Components"
    theme="light"
    @success="onCopySuccess"
  />
</template>

<script>
import VueDemoEditor from 'vue-demo-editor'
import * as Components from "your-component-kit"

export default {
  components: {
    VueDemoEditor 
  },
  data() {
    return {
      demoCode: `
        <template>
          <button @click="count++">
            点击了 {{ count }} 次
          </button>
        </template>
        
        <script>
        export default {
          data() {
            return {
              count: 0
            }
          }
        }
        </script>
      `,
    }
  },
  methods: {
    onCopySuccess() {
      console.log('代码已复制到剪贴板')
    }
  }
}
</script>

属性

参数说明类型必填项默认值
theme主题风格,lightdarkStringlight
code要展示的演示代码String-
components演示需要注册的组件Object-
success复制成功的回调函数Function-

自定义样式

默认的语法高亮主题是 prismjs/themes/prism-coy.min.css。你可以通过导入其他 PrismJS 主题来自定义:

import 'prismjs/themes/prism-dark.css' 

Git commit ⻛格指南

  • feat: 增加新功能
  • fix: 修复问题
  • style: 代码⻛格相关⽆影响运⾏结果的
  • perf: 优化/性能提升
  • refactor: 重构
  • revert: 撤销修改
  • test: 测试相关
  • docs: ⽂档/注释
  • chore: 依赖更新/脚⼿架配置修改等
  • ci: 持续集成

许可证

该项目基于 MIT 许可证进行分发。更多详情请参阅 LICENSE 文件。

0.1.14

7 months ago

0.1.12

8 months ago

0.1.11

8 months ago

0.1.10

8 months ago

0.1.9

8 months ago

0.1.8

8 months ago

0.1.7

8 months ago

0.1.6

8 months ago

0.1.5

8 months ago

0.1.4

8 months ago

0.1.3

8 months ago

0.1.2

8 months ago

0.1.1

8 months ago

0.1.0

8 months ago