[英]Nextjs: How to register the quill-blot-formatter to dynamically imported react-quill on client side rendering only?
[英]Quill-blot-formatter is not registering with react-quill on import through next/dynamic and keeps showing loading
我制作了一個 function 組件,我在其中使用react-quill
quill 注冊了 quill quill-blot-formatter
並在模塊列表中添加了blotFormatter
。 然后我在我想要的頁面上用next/dynamic
導入了這個模塊。
定制 function:
import ReactQuill, { Quill } from 'react-quill';
import { BlotFormatter } from 'quill-blot-formatter';
import 'react-quill/dist/quill.snow.css'
Quill.register("modules/blotFormatter", BlotFormatter);
const modules = {
blotFormatter: {
overlay: {
style: { border: '2px solid red',}
}},
toolbar: [...],
}
const formats = [...];
我從react-quill
quill 調用默認的ReactQuill
導出,如下所示:
export default function QuillCustom({onChange}) {
return (
<ReactQuill
modules={modules}
formats={formats}
theme="snow"
onChange={onchange}
readOnly={false}
/>
);
}
在 Nextjs 頁面組件上,我這樣稱呼它:
const QuillNoSSRWrapper = dynamic(() => import('../Components/quillComponent'), {
ssr: false,
loading: () => <p>Loading...</p>,
})
return (
<div>
<QuillNoSSRWrapper
className={styles.quillTextArea}
onChange={handleTextChange}
/>
</div>
)
現在,問題是,在頁面加載后,在const QuillNoSSRWrapper
中聲明的loading...
屬性會顯示在屏幕上並永遠留在那里。 羽毛筆編輯器不出現。
我試着評論這一行: Quill.register("modules/blotFormatter", BlotFormatter);
在自定義模塊上,然后出現羽毛筆編輯器。 blotFormatter
模塊是否未向 Quill 注冊? 那我怎么注冊呢?
對不起這是我的錯! BlotFormatter
是默認導入。
import BlotFormatter from 'quill-blot-formatter';
聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.