简体   繁体   English

换行符在 Firestore 中不起作用

[英]The line break doesn't work in the firestore

I use vue 3 and firestore.我使用 vue 3 和 Firestore。

When I was writing, Even though I pressed the enter key to break the line, it only works to write space.当我写的时候,即使我按回车键换行,它也只能写空格。

在此处输入图像描述

在此处输入图像描述

in firestore在火库

在此处输入图像描述

This is my code.这是我的代码。

<div class="form-group">
  <textarea class="form-control" cols="30" rows="10" v-model="content" required></textarea>
</div>

await db.collection('forms').add(
      {
        title: title.value, content: content.value, createdAt, updatedAt, uid, name, views
      }
    )

How can I use line break?如何使用换行符?

Line breaks in Firestore are preserved as written, the issue is that the rendering mechanics inside Firestore are styled to ignore line breaks to preserve the structure of Firestore documents. Firestore 中的换行符按书面形式保留,问题在于 Firestore 中的渲染机制被设计为忽略换行符以保留 Firestore 文档的结构。

you can see this if you download the document snapshot and render the text inside a text area box, for a website, you may have to replace the newlines with a web safe alternative such as <br />如果您下载文档快照并在文本区域框中呈现文本,您可以看到这一点,对于网站,您可能必须用 web 安全替代品替换换行符,例如<br />

I just added style="white-space:pre-line" and it works!我刚刚添加了 style="white-space:pre-line" 并且它有效!

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM