vue 使用quill富文本编辑器时, 编辑器的空格不回显 [坑!]
- 安装
npm i quill@2.0.3 --save
- html
<!-- Quill 编辑器容器 -->
<div class="editor" ref="editor"></div>
- script
import Quill from "quill";
import "quill/dist/quill.core.css";
import "quill/dist/quill.snow.css";
import "quill/dist/quill.bubble.css";
// dangerouslyPasteHTML为编辑器赋初始html内容时, 先将连续的空格转为
this.Quill = new Quill(editor, this.options);
this.htmlValue = this.htmlValue.replace(/ {2,}/g, s => " ".repeat(s.length));
this.Quill.clipboard.dangerouslyPasteHTML(this.htmlValue);
- css
.editor, .ql-toolbar {
white-space: pre-wrap !important;
line-height: normal !important;
}

被折叠的 条评论
为什么被折叠?



