Editor.js 在 Vue 中初始化后无法输入内容是怎么回事?

诸葛柯豫 阅读 3

我在 Vue 3 项目里集成 Editor.js,初始化看起来没问题,编辑器也渲染出来了,但就是点进去没法输入文字,光标都出不来。试过官方 demo 的配置,也检查了容器是否有高度,还是不行。

这是我的组件代码:

<template>
  <div ref="editorContainer" class="editor-container"></div>
</template>

<script setup>
import EditorJS from '@editorjs/editorjs'
import { onMounted, ref } from 'vue'

const editorContainer = ref(null)

onMounted(() => {
  new EditorJS({
    holder: editorContainer.value,
    tools: {}
  })
})
</script>
我来解答 赞 4 收藏
二维码
手机扫码查看
1 条解答
W″尚文
我之前也遇到过,Editor.js在Vue3里要用nextTick等DOM完全渲染再初始化。改下onMounted里的代码:


onMounted(() => {
nextTick(() => {
new EditorJS({
holder: editorContainer.value,
tools: {}
})
})
})


记得import nextTick。另外检查下CSS,确保容器有min-height
点赞
2026-03-06 13:08