Nuxt 3+Quill编辑器:Quill:toolbar工具栏所需的容器



有人,请帮帮我,我被这个问题困扰了3个多小时,我尝试使用Nuxt 3和带有自定义工具栏的quill编辑器,这是代码

html

<client-only>
<QuillEditor
theme="snow"
ref="quill"
contentType="html"
:options="editorOption"
toolbar="#toolbar"
v-model:content="forms.content"
/>
</client-only>

js

data(){
return {
editorOption: {
theme: "snow",
placeholder: "Write something...",
modules: {
toolbar: "#toolbar"
},
},
}
}

错误

quill:toolbar Container required for toolbar 
{
"container": "#toolbar",
"handlers": {}
}
[Vue warn]: Unhandled error during execution of mounted hook 
at <QuillEditor theme="snow" ref="quill" contentType="html"
Vue Quill希望您定义自定义工具栏。当您定义了一个自定义工具栏选择器"#toolbar",但实际上并没有将工具栏放在任何位置(它正在寻找id为"toolbar"的元素(时,就会发生这种错误。

这可能是因为当使用ssr时,Nuxt试图在服务器端渲染,但它不存在。此外,我真的不确定quill目前是否会支持Vite,所以我建议使用像vue3 quill editor Vite这样的软件包。

最新更新