【问题标题】:Set the Content of Quill.js by external HTML通过外部 HTML 设置 Quill.js 的内容
【发布时间】:2018-04-01 18:12:25
【问题描述】:

我尝试使用外部 html 设置 quill.js 的内容,如下所示:

quill.container.querySelector('.ql-editor').innerHTML = myHtml;

但并非所有 myHtml 代码都显示在编辑器中!

当我这样做时:

document.getElementById("editor").innerHTML = myHtml; 

整个 html 都在那里,但没有给出编辑功能(因为在 #editor 内部有 .ql-editor 被覆盖。

请看这里: https://fiddle.jshell.net/ppkxL2pd/16/

随意更改两个给定的可能性以理解我的意思。

为什么 myHtml 显示不正确?

【问题讨论】:

    标签: javascript quill


    【解决方案1】:

    问题在于您将 html 分配给 myHtml 变量的方式。

    您正确地使用了反引号作为模板文字,但在这种特殊情况下它似乎不起作用。

    解决方案:

    1. 将整个 html 保留在一行中。 (不好的方式)。 Working Demo here
    2. 在每一行的末尾使用\Working Demo here

    【讨论】:

      猜你喜欢
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 2020-04-06
      • 1970-01-01
      • 1970-01-01
      相关资源
      最近更新 更多