Home

Awesome

svelte-vditor-demo

English | 简体中文

在Svelte框架使用Vditor的demo, 源码详见 App.svelte

使用过程

# 初始化工程
npx degit sveltejs/template my-svelte-project

# 下载依赖
npm install
+ <link rel="stylesheet" href="https://cdn.jsdelivr.net/npm/vditor/dist/index.css"/>

示例: src/App.svelte

<script>
+    import { onMount } from "svelte"
+    import Vditor from "vditor"

+    onMount(() => {
+        const vditor = new Vditor("vditor-container", {
+            theme: "classic",
+            minHeight: 600,
+        })
+    })
</script>

+<div id="vditor-container" />

<style>
</style>
  1. 为Vditor添加挂载DOM
  2. onMount生命周期引入Vditor初始化