简体   繁体   中英

The line break doesn't work in the firestore

I use vue 3 and 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.

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 />

I just added style="white-space:pre-line" and it works!

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

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