Vanessa219 / vditor

♏ 一款浏览器端的 Markdown 编辑器,支持所见即所得(富文本)、即时渲染(类似 Typora)和分屏预览模式。An In-browser Markdown editor, support WYSIWYG (Rich Text), Instant Rendering (Typora-like) and Split View modes.
https://b3log.org/vditor
MIT License
8.35k stars 857 forks source link

TypeError: Cannot read properties of undefined (reading 'cdn') #1596

Closed XCLHove closed 6 months ago

XCLHove commented 6 months ago

编辑模式

描述问题

代码:

<script setup lang="ts">
import {onMounted, ref} from "vue";
import Vditor from 'vditor'
import 'vditor/dist/index.css'

const vditor = ref<HTMLDivElement>()

onMounted(() => {
  Vditor.preview(vditor.value, '# title')
})
</script>

<template>
  <div class="container">
    <div ref="vditor"></div>
  </div>
</template>

<style scoped>
.container {
  box-sizing: border-box;
  padding: 30px 0;
}
</style>

期待的结果

页面正常渲染

截屏或录像

image.png

版本信息

其他信息

Vanessa219 commented 6 months ago

demo 上是正常的,这个错误信息看不出具体的问题。

XCLHove commented 6 months ago

配置一下cdn就好了:

Vditor.preview(vditor.value, '# title', {
    cdn: 'https://unpkg.com/vditor@3.10.2'
})
XCLHove commented 6 months ago

依赖包中有对应js为什么还要去cdn拿,不是很能理解

Vanessa219 commented 6 months ago

lute 太大了