vditor icon indicating copy to clipboard operation
vditor copied to clipboard

不知道有没有人遇到vditor无法放到tabs里渲染的情况,可以用以下方式试试

Open nejinn opened this issue 3 years ago • 3 comments

编辑模式

  • wysiwyg 所见即所得模式
  • ir 即时渲染模式
  • sv 分屏编辑预览模式

描述问题

在vue中,如果是把 vditior 放到 tabs 里渲染,比如现在比较流行的 tabs 路由 image

按照官方的写法,并不会渲染多个编辑器,切换路由的时候,其他tab的编辑器是空的,多个tab,只会有一个会渲染。

如果是解析渲染问题的话请在此处贴入 Markdown 原文

解决方式

动态渲染id就可以

官方写法

<div id="vditor" name="description"></div>

mounted() {
   this.contentEditor = new Vditor('vditor', {})
}

动态渲染id

<div :id="mdId" name="description"></div>
data() {
   return {
     mdId:""
  };
},
mounted() {
  this.mdId = this.$route.path
  this.contentEditor = new Vditor(this.mdId, {})
}

nejinn avatar Oct 05 '21 14:10 nejinn

这个可以等页签切换后再进行初始化

Vanessa219 avatar Oct 05 '21 16:10 Vanessa219

@Vanessa219 重新初始化是不行的,会导致内容丢失,或者出现其他问题

nejinn avatar Oct 06 '21 02:10 nejinn

我的意思是在 tab 切换以后再去初始化 vditor

Vanessa219 avatar Oct 06 '21 14:10 Vanessa219