Closed XCLHove closed 3 months ago
ir
代码:
<script setup lang="ts"> import {onMounted} from "vue"; import Vditor from 'vditor' import 'vditor/dist/index.css' let vditor: Vditor = null onMounted(() => { vditor = new Vditor('vditor', {}) console.log(vditor.getValue()) }) </script> <template> <div class="container"> <div id="vditor"></div> </div> </template> <style scoped> .container { box-sizing: border-box; padding: 30px 0; } </style>
报错:
TypeError: Cannot read properties of undefined (reading 'currentMode') at a (index.min.js:1:64846) at t3.getValue (index.min.js:1:262946) at App.vue?t=1711609992352:12:26
demo 上是正常的,这个错误信息看不出具体的问题。
请问怎么解决的?
如果new了Vditor之后,马上操作vditor对象,就会报错。把操作逻辑移动到 点击事件里,延迟操作vditor的时机。 就运行正常了。 目测Viditor没有初始化完成。
这里有初始化完成的回调事件吗? @Vanessa219 这种情况下如何处理比较好?
我看到了,用after回调函数
编辑模式
ir
即时渲染模式描述问题
代码:
报错:
期待的结果
截屏或录像
版本信息
其他信息