Ota*_*sto 1 javascript reactjs quill react-ace
我试图使用 ReactQuill 只是为了显示我拥有的一些富文本,因此我不希望它可以接收用户的任何输入或键入。原因,我有另一个库(ReactAce),ReactQuill 导致了一个错误,当我键入“删除”键时,它使 ReactAce 停止工作......
您可以在下面看到我正在尝试禁用 Quill 实例的示例。
quillRef = React.createRef();
componentDidMount = () => {
console.log(this.quillRef.current.editor);
this.quillRef.current.editor.enable(false); // undefined
};
render () {
<ReactQuill
readOnly
value={info}
ref={this.quillRef}
modules={quillConfig}
>
}
Run Code Online (Sandbox Code Playgroud)
如果您知道某种方法可以阻止 ReactQuill 接收来自键盘的任何输入,我会很高兴,因为我认为这是导致该错误的原因。
谢谢你!
小智 5
readOnly您可以按如下方式使用该属性:
<ReactQuilltheme="snow" readOnly={true} />
Run Code Online (Sandbox Code Playgroud)
当然,您需要使用使其动态化useState()
const [disabled, setDisabled] = useState(true);
return (
<ReactQuilltheme="snow" readOnly={disabled} />
)
Run Code Online (Sandbox Code Playgroud)
| 归档时间: |
|
| 查看次数: |
9615 次 |
| 最近记录: |