【问题标题】:suneditor-react Typescript getContent is not workingsuneditor-react Typescript getContent 不起作用
【发布时间】:2021-05-22 14:50:24
【问题描述】:

我正在使用 suneditor-reacttypescript。我想获取编辑器的内容创建 PDF。但问题是当我尝试访问 SunEditor 的 ref 时,出现以下错误

Property 'ref' does not exist on type 'IntrinsicAttributes & SunEditorReactProps & { children?: ReactNode; }'. 

此外,我在SunEditorReactProps 中也找不到getContents() 道具。但它在他们的示例页面中。

请提出你的想法。

sunediotr-react

suneditor example page

【问题讨论】:

    标签: reactjs typescript suneditor


    【解决方案1】:

    您好,我是 SunEditor React 组件的作者,您可以学习如何将 ref 附加到 suneditor react 组件(在 typescript 中)here

    【讨论】:

      【解决方案2】:
      1. 导入 SuneditorCore
      import SunEditorCore from "suneditor/src/lib/core";
      

      2)给定变量的声明和设置值

      private suneditor1!:SunEditorCore;
      this.suneditor1=suneditor.create('sample', {
                  
      });
      

      3)调用 suneditor 函数

      const savedata=this.suneditor1.getContents(true); 
      

      【讨论】:

        猜你喜欢
        • 2019-10-26
        • 2021-01-28
        • 1970-01-01
        • 2021-04-08
        • 2019-06-18
        • 2023-01-24
        • 2019-11-29
        • 1970-01-01
        • 1970-01-01
        相关资源
        最近更新 更多