首页 > 解决方案 > react-quill 在输入时添加额外的换行符

问题描述

我正在使用 react-quill 并从

但是,存在额外换行符的问题。

这是我的输入以及我希望它在后端传递时的样子(qna 制造商)

<div>
  test1 <br>
  test2 <br>
  test3 <br>
</div>

但它变成了这样:

<div> test1 </div>
<div> test2 </div>
<div> test3 </div>

所以当我将它传递给后端时,它会像这样保存

test1\n\ntest2\n\ntest3 实际上我只想将它保存为 test1\n\ntest2\ntest3

我用过这个:

 var Block = Quill.import('blots/block');
    Block.tagName = 'DIV';
    Quill.register(Block, true);
```````
 <ReactQuill
            value={this.props.value}
            onChange={this.handleChange}
            onBlur={this.setProps}
            modules={this.modules}
            formats={this.formats}
          />

这是正在保存的标记:

    <div>click <a href=\"https://twitter.com\" target=\"_blank\">here </a> for sample link test test testing test new line sample link <a href=\"https://www.google.com\" target=\"_blank\">here</a>.. and then <a href=\"https://www.facebook.com\" target=\"_blank\">here</a> test here</div>
<div>endtered value here</div>
<div><br></div>
<div><br></div>
<div>this is a new paragraphs</div>
<div>but this is just a new line</div>

这就是它在 qnamaker 中的样子

在此处输入图像描述

标签: reactjsquill

解决方案


推荐阅读